From 80de74e12732f4884bd9bf5bf113992ac5bd544e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 25 Apr 2020 14:27:44 +0100 Subject: [PATCH] cancel keepalive if http status not OK, this maybe a bit 2 hardm but ok for now --- .../Servers/HttpServer/OSHttpRequest.cs | 2 +- .../HttpServer/OSHttpServer/HttpResponse.cs | 21 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs index 5c7f74860b..ffb54689be 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs @@ -161,7 +161,7 @@ namespace OpenSim.Framework.Servers.HttpServer /// // public Hashtable Form { get; private set; } - public string RawUrl + public string RawUrl { get { return m_request.Uri.AbsolutePath; } } diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpResponse.cs index a291981a36..8a247086ce 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpResponse.cs @@ -246,14 +246,25 @@ namespace OSHttpServer if (m_headers["Server"] == null) sb.Append("Server: OSWebServer\r\n"); - int keepaliveS = m_context.TimeoutKeepAlive / 1000; - if (Connection == ConnectionType.KeepAlive && keepaliveS > 0 && m_context.MaxRequests > 0) + if(Status != HttpStatusCode.OK) { - sb.AppendFormat("Keep-Alive:timeout={0}, max={1}\r\n", keepaliveS, m_context.MaxRequests); - sb.Append("Connection: Keep-Alive\r\n"); + sb.Append("Connection: close\r\n"); + Connection = ConnectionType.Close; } else - sb.Append("Connection: close\r\n"); + { + int keepaliveS = m_context.TimeoutKeepAlive / 1000; + if (Connection == ConnectionType.KeepAlive && keepaliveS > 0 && m_context.MaxRequests > 0) + { + sb.AppendFormat("Keep-Alive:timeout={0}, max={1}\r\n", keepaliveS, m_context.MaxRequests); + sb.Append("Connection: Keep-Alive\r\n"); + } + else + { + sb.Append("Connection: close\r\n"); + Connection = ConnectionType.Close; + } + } if (m_headers["Connection"] != null) m_headers["Connection"] = null;