aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src
diff options
context:
space:
mode:
authorPéter Dimitrov <[email protected]>2018-08-27 15:58:40 +0200
committerPéter Dimitrov <[email protected]>2018-08-27 15:58:40 +0200
commitab8faff46daf24db6f20dc2a307cf68d53034450 (patch)
treee5d90d8a9d7882a04722bcfb857ccb0b2055dc72 /lib/inets/src
parent30b5899883282b746b55fbf59b73211bbd071ddd (diff)
parentd3962078e76f1f04af12aecbea9d0fc33df3ea62 (diff)
downloadotp-ab8faff46daf24db6f20dc2a307cf68d53034450.tar.gz
otp-ab8faff46daf24db6f20dc2a307cf68d53034450.tar.bz2
otp-ab8faff46daf24db6f20dc2a307cf68d53034450.zip
Merge branch 'peterdmv/inets/fix_http_client/OTP-15242' into maint-20
* peterdmv/inets/fix_http_client/OTP-15242: inets: Prepare for release inets: Robust handling of 204, 304, 1xx responses Change-Id: I12dced982907c3462fefb8a4ffaae8b365821f97
Diffstat (limited to 'lib/inets/src')
-rw-r--r--lib/inets/src/http_client/httpc_handler.erl18
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 26e4f4e699..1a2ce277bf 100644
--- a/lib/inets/src/http_client/httpc_handler.erl
+++ b/lib/inets/src/http_client/httpc_handler.erl
@@ -980,13 +980,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,