LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0269-inets-Improve-readability-of-handling-of-server-Conn.patch of Package erlang (Project home:Ledest:erlang:20)

From d9d40dd446d7e7783ceaff62f0bc5f74e556d119 Mon Sep 17 00:00:00 2001
From: Luca Favatella <luca.favatella@erlang-solutions.com>
Date: Fri, 6 Apr 2018 10:45:28 +0100
Subject: [PATCH 9/9] inets: Improve readability of handling of server
 `Connection: close`

Addresses https://github.com/erlang/otp/pull/1752#discussion_r177970060
---
 lib/inets/src/http_client/httpc_handler.erl | 24 +++++++++---------------
 1 file 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, 
-- 
2.16.3