]> granicus.if.org Git - icinga2/commitdiff
Ensure that HTTP/1.0 or Connection: close headers are properly disconnecting the... 6658/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Tue, 9 Oct 2018 11:23:23 +0000 (13:23 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Tue, 9 Oct 2018 11:23:23 +0000 (13:23 +0200)
Test results: https://github.com/Icinga/icinga2/issues/6514#issuecomment-428155731

fixes #6514

lib/remote/httpresponse.cpp
lib/remote/httpserverconnection.cpp

index 45ac25c817143546a391fbfd706b2b365e6ee358..cfe99d6081b6a0b5abe288a2bd1a16ffb85a8e5a 100644 (file)
@@ -111,9 +111,6 @@ void HttpResponse::Finish()
        }
 
        m_State = HttpResponseEnd;
-
-       if (m_Request->ProtocolVersion == HttpVersion10 || m_Request->Headers->Get("connection") == "close")
-               m_Stream->Shutdown();
 }
 
 bool HttpResponse::Parse(StreamReadContext& src, bool may_wait)
index 497ce7b83c447f8f4c95b58943b420facbbaba68..aa960c25b1c665161047bae71aecd28d8d40514b 100644 (file)
@@ -357,6 +357,13 @@ void HttpServerConnection::DataAvailableHandler()
                }
 
                m_RequestQueue.Enqueue(std::bind(&Stream::SetCorked, m_Stream, false));
+
+               /* Request finished, decide whether to explicitly close the connection. */
+               if (m_CurrentRequest.ProtocolVersion == HttpVersion10 ||
+                       m_CurrentRequest.Headers->Get("connection") == "close") {
+                       m_Stream->Shutdown();
+                       close = true;
+               }
        } else
                close = true;