Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Content length empty body #23

Merged
1 commit merged into from

1 participant

@fdmanana

Hi Chandru,

Here's the pull request for issue 21.

Thanks for looking into this.

@fdmanana fdmanana Two changes:
1) Set Content-Length to 0 for empty PUT and POST requests (necessary for some proxies);

2) Use iolist_size/1 instead of size/1 or length/1 because the body can be an iolist
9611896
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 16, 2010
  1. @fdmanana

    Two changes:

    fdmanana authored
    1) Set Content-Length to 0 for empty PUT and POST requests (necessary for some proxies);
    
    2) Use iolist_size/1 instead of size/1 or length/1 because the body can be an iolist
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 10 deletions.
  1. +6 −10 src/ibrowse_http_client.erl
View
16 src/ibrowse_http_client.erl
@@ -831,17 +831,13 @@ make_request(Method, Headers, AbsPath, RelPath, Body, Options,
Headers_0 = [Fun1(X) || X <- Headers],
Headers_1 =
case lists:keysearch("content-length", 1, Headers_0) of
- false when (Body == []) orelse
- (Body == <<>>) orelse
- is_tuple(Body) orelse
- is_function(Body) ->
- Headers_0;
- false when is_binary(Body) ->
- [{"content-length", "content-length", integer_to_list(size(Body))} | Headers_0];
- false when is_list(Body) ->
- [{"content-length", "content-length", integer_to_list(length(Body))} | Headers_0];
+ false when (Body == [] orelse Body == <<>>) andalso
+ (Method == post orelse Method == put) ->
+ [{"content-length", "Content-Length", "0"} | Headers_0];
+ false when is_binary(Body) orelse is_list(Body) ->
+ [{"content-length", "Content-Length", integer_to_list(iolist_size(Body))} | Headers_0];
_ ->
- %% Content-Length is already specified
+ %% Content-Length is already specified or Body is a function or function/state pair
Headers_0
end,
{Headers_2, Body_1} =
Something went wrong with that request. Please try again.