aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_client/httpc_handler.erl
diff options
context:
space:
mode:
authorLuca Favatella <[email protected]>2018-04-06 10:45:28 +0100
committerLuca Favatella <[email protected]>2018-04-06 11:07:48 +0100
commitd9d40dd446d7e7783ceaff62f0bc5f74e556d119 (patch)
treece12668c01c5ee7d5a6861f629df445b6f8d720e /lib/inets/src/http_client/httpc_handler.erl
parentb1567acdbe2c0189e39eb5f0cb696773dd7d1961 (diff)
downloadotp-d9d40dd446d7e7783ceaff62f0bc5f74e556d119.tar.gz
otp-d9d40dd446d7e7783ceaff62f0bc5f74e556d119.tar.bz2
otp-d9d40dd446d7e7783ceaff62f0bc5f74e556d119.zip
inets: Improve readability of handling of server `Connection: close`
Addresses https://github.com/erlang/otp/pull/1752#discussion_r177970060
Diffstat (limited to 'lib/inets/src/http_client/httpc_handler.erl')
-rw-r--r--lib/inets/src/http_client/httpc_handler.erl24
1 files changed, 9 insertions, 15 deletions
diff --git a/lib/inets/src/http_client/httpc_handler.erl b/lib/inets/src/http_client/httpc_handler.erl
index 945b1b94b6..eeb08ce0ee 100644
--- a/lib/inets/src/http_client/httpc_handler.erl
+++ b/lib/inets/src/http_client/httpc_handler.erl
@@ -1040,21 +1040,7 @@ handle_response(#state{status = new} = State) ->
handle_response(try_to_enable_pipeline_or_keep_alive(State));
handle_response(#state{status = Status0} = State0) when Status0 =/= new ->
- Status =
- case Status0 of
- close -> close;
- _ ->
- case State0#state.headers of
- undefined -> Status0;
- _ ->
- case httpc_response:is_server_closing(
- State0#state.headers) of
- true -> close;
- false -> Status0
- end
- end
- end,
- State = State0#state{status = Status},
+ State = handle_server_closing(State0),
#state{request = Request,
session = Session,
status_line = StatusLine,
@@ -1325,6 +1311,14 @@ try_to_enable_pipeline_or_keep_alive(
State#state{status = close}
end.
+handle_server_closing(State = #state{status = close}) -> State;
+handle_server_closing(State = #state{headers = undefined}) -> State;
+handle_server_closing(State = #state{headers = Headers}) ->
+ case httpc_response:is_server_closing(Headers) of
+ true -> State#state{status = close};
+ false -> State
+ end.
+
answer_request(#request{id = RequestId, from = From} = Request, Msg,
#state{session = Session,
timers = Timers,