diff options
author | Péter Dimitrov <[email protected]> | 2018-08-27 16:31:07 +0200 |
---|---|---|
committer | Péter Dimitrov <[email protected]> | 2018-08-27 16:31:07 +0200 |
commit | 3b7517df17b30839251b1fd3b070999d6f03bcb5 (patch) | |
tree | e325aa5ec8e48c6db7ad888efb77c71debd085f3 /lib/inets/src/http_client | |
parent | 0960ef90d717f5851037903b81e364fae1a43cdf (diff) | |
parent | 7db7a1caeeee21682f37cfa95f9f026074e03ccf (diff) | |
download | otp-3b7517df17b30839251b1fd3b070999d6f03bcb5.tar.gz otp-3b7517df17b30839251b1fd3b070999d6f03bcb5.tar.bz2 otp-3b7517df17b30839251b1fd3b070999d6f03bcb5.zip |
Merge branch 'maint'
* maint:
inets: Prepare for release
inets: Robust handling of 204, 304, 1xx responses
inets: Do not use chunked encoding with 1xx, 204, 304
Change-Id: Ia739a7b1a7f1482194def99d039b5a7c8133a6ca
Diffstat (limited to 'lib/inets/src/http_client')
-rw-r--r-- | lib/inets/src/http_client/httpc_handler.erl | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/inets/src/http_client/httpc_handler.erl b/lib/inets/src/http_client/httpc_handler.erl index 5e05b8170a..1bf5d25c98 100644 --- a/lib/inets/src/http_client/httpc_handler.erl +++ b/lib/inets/src/http_client/httpc_handler.erl @@ -961,13 +961,23 @@ handle_http_body(_, #state{status = {ssl_tunnel, Request}, NewState = answer_request(Request, ClientErrMsg, State), {stop, normal, NewState}; -handle_http_body(<<>>, #state{status_line = {_,304, _}} = State) -> +%% All 1xx (informational), 204 (no content), and 304 (not modified) +%% responses MUST NOT include a message-body, and thus are always +%% terminated by the first empty line after the header fields. +%% This implies that chunked encoding MUST NOT be used for these +%% status codes. +handle_http_body(<<>>, #state{headers = Headers, + status_line = {_,StatusCode, _}} = State) + when Headers#http_response_h.'transfer-encoding' =/= "chunked" andalso + (StatusCode =:= 204 orelse %% No Content + StatusCode =:= 304 orelse %% Not Modified + 100 =< StatusCode andalso StatusCode =< 199) -> %% Informational handle_response(State#state{body = <<>>}); -handle_http_body(<<>>, #state{status_line = {_,204, _}} = State) -> - handle_response(State#state{body = <<>>}); -handle_http_body(<<>>, #state{request = #request{method = head}} = State) -> +handle_http_body(<<>>, #state{headers = Headers, + request = #request{method = head}} = State) + when Headers#http_response_h.'transfer-encoding' =/= "chunked" -> handle_response(State#state{body = <<>>}); handle_http_body(Body, #state{headers = Headers, |