From 080f666b55a7570de68ccd6659f12766d5efe179 Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Mon, 3 Dec 2018 14:27:37 +0100 Subject: [PATCH] Restore 'Connection: close' behaviour in HTTP responses Actually the `corked` functionality caused problems with not closing connections properly. Full Analysis: https://github.com/Icinga/icinga2/issues/6799#issuecomment-443710338 Full credits to @swegener :) fixes #6799 --- lib/remote/httpresponse.cpp | 3 +++ lib/remote/httpserverconnection.cpp | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/remote/httpresponse.cpp b/lib/remote/httpresponse.cpp index fe67052c9..ef0df7e81 100644 --- a/lib/remote/httpresponse.cpp +++ b/lib/remote/httpresponse.cpp @@ -111,6 +111,9 @@ 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) diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp index 4f619d2f1..cd3e542f2 100644 --- a/lib/remote/httpserverconnection.cpp +++ b/lib/remote/httpserverconnection.cpp @@ -362,13 +362,6 @@ void HttpServerConnection::DataAvailableHandler() close = true; } - - /* 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; -- 2.40.0