Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content length empty body #23

Merged
1 commit merged into from
Dec 14, 2010
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/ibrowse_http_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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} =
Expand Down