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

Support identity transfer-encoding in httpc #288

Merged
merged 1 commit into from Mar 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/inets/src/http_client/httpc_handler.erl
Expand Up @@ -1119,15 +1119,8 @@ handle_http_body(Body, #state{headers = Headers,
handle_response(State#state{headers = NewHeaders,
body = NewBody})
end;
Encoding when is_list(Encoding) ->
?hcrt("handle_http_body - encoding", [{encoding, Encoding}]),
NewState = answer_request(Request,
httpc_response:error(Request,
unknown_encoding),
State),
{stop, normal, NewState};
_ ->
?hcrt("handle_http_body - other", []),
Enc when Enc =:= "identity"; Enc =:= undefined ->
?hcrt("handle_http_body - identity", []),
Length =
list_to_integer(Headers#http_response_h.'content-length'),
case ((Length =< MaxBodySize) orelse (MaxBodySize =:= nolimit)) of
Expand All @@ -1149,7 +1142,14 @@ handle_http_body(Body, #state{headers = Headers,
body_too_big),
State),
{stop, normal, NewState}
end
end;
Encoding when is_list(Encoding) ->
?hcrt("handle_http_body - other", [{encoding, Encoding}]),
NewState = answer_request(Request,
httpc_response:error(Request,
unknown_encoding),
State),
{stop, normal, NewState}
end.

handle_response(#state{status = new} = State) ->
Expand Down
14 changes: 14 additions & 0 deletions lib/inets/test/httpc_SUITE.erl
Expand Up @@ -104,6 +104,7 @@ only_simulated() ->
remote_socket_close,
remote_socket_close_async,
transfer_encoding,
transfer_encoding_identity,
redirect_loop,
redirect_moved_permanently,
redirect_multiple_choises,
Expand Down Expand Up @@ -624,6 +625,12 @@ transfer_encoding(Config) when is_list(Config) ->

%%-------------------------------------------------------------------------

transfer_encoding_identity(Config) when is_list(Config) ->
URL = url(group_name(Config), "/identity_transfer_encoding.html", Config),
{ok, {{_,200,_}, [_|_], "IDENTITY"}} = httpc:request(URL).

%%-------------------------------------------------------------------------

empty_response_header() ->
[{doc, "Test the case that the HTTP server does not send any headers. Solves OTP-6830"}].
empty_response_header(Config) when is_list(Config) ->
Expand Down Expand Up @@ -1609,6 +1616,13 @@ handle_uri(_,"/capital_transfer_encoding.html",_,_,Socket,_) ->
send(Socket, http_chunk:encode("obar</BODY></HTML>")),
http_chunk:encode_last();

handle_uri(_,"/identity_transfer_encoding.html",_,_,_,_) ->
"HTTP/1.0 200 OK\r\n"
"Transfer-Encoding:identity\r\n"
"Content-Length:8\r\n"
"\r\n"
"IDENTITY";

handle_uri(_,"/cookie.html",_,_,_,_) ->
"HTTP/1.1 200 ok\r\n" ++
"set-cookie:" ++ "test_cookie=true; path=/;" ++
Expand Down