From e2f84f0c1fac42f2b2a2493d0d272826abde734f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 16 Apr 2020 02:13:03 +0100 Subject: [PATCH] send 100 continue code the way ms seems to want --- .../OSHttpServer/HttpClientContext.cs | 18 +++++++++++------- .../OSHttpServer/HttpContextFactory.cs | 1 - .../HttpServer/OSHttpServer/HttpRequest.cs | 4 ++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpClientContext.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpClientContext.cs index 625f0bfff3..6059afcb2a 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpClientContext.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpClientContext.cs @@ -140,6 +140,7 @@ namespace OSHttpServer basecontextID = 1; contextID = basecontextID; + sock.NoDelay = true; } public bool CanSend() @@ -175,7 +176,7 @@ namespace OSHttpServer lock (requestsInServiceIDs) { if (requestsInServiceIDs.Count == 0) - Respond("HTTP/1.1", HttpStatusCode.Continue, "Please continue."); + Respond("HTTP/1.1", HttpStatusCode.Continue, null); } } m_currentRequest.AddHeader(e.Name, e.Value); @@ -557,20 +558,21 @@ namespace OSHttpServer { LastActivityTimeMS = ContextTimeoutManager.EnvironmentTickCount(); - if (string.IsNullOrEmpty(contentType)) - contentType = "text/html"; - if (string.IsNullOrEmpty(reason)) reason = statusCode.ToString(); byte[] buffer; if(string.IsNullOrEmpty(body)) - buffer = Encoding.ASCII.GetBytes(httpVersion + " " + (int)statusCode + " " + reason ?? statusCode.ToString() + "\r\n\r\n"); + buffer = Encoding.ASCII.GetBytes(httpVersion + " " + (int)statusCode + " " + reason + "\r\n\r\n"); else + { + if (string.IsNullOrEmpty(contentType)) + contentType = "text/html"; buffer = Encoding.UTF8.GetBytes( string.Format("{0} {1} {2}\r\nContent-Type: {5}\r\nContent-Length: {3}\r\n\r\n{4}", httpVersion, (int)statusCode, reason ?? statusCode.ToString(), body.Length, body, contentType)); + } Send(buffer); } @@ -582,8 +584,10 @@ namespace OSHttpServer /// reason for the status code. public void Respond(string httpVersion, HttpStatusCode statusCode, string reason) { - - Respond(httpVersion, statusCode, reason, null, null); + if (string.IsNullOrEmpty(reason)) + reason = statusCode.ToString(); + byte[] buffer = Encoding.ASCII.GetBytes(httpVersion + " " + (int)statusCode + " " + reason + "\r\n\r\n"); + Send(buffer); } /// diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpContextFactory.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpContextFactory.cs index eb951e24e4..447beb532f 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpContextFactory.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpContextFactory.cs @@ -103,7 +103,6 @@ namespace OSHttpServer public IHttpClientContext CreateSecureContext(Socket socket, X509Certificate certificate, SslProtocols protocol, RemoteCertificateValidationCallback _clientCallback = null) { - socket.NoDelay = true; var networkStream = new NetworkStream(socket, true); var remoteEndPoint = (IPEndPoint)socket.RemoteEndPoint; diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequest.cs index 2675130e54..f520245f7e 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequest.cs @@ -402,6 +402,7 @@ namespace OSHttpServer throw new BadRequestException("Unknown 'Connection' header type."); break; + /* case "expect": if (value.Contains("100-continue")) { @@ -409,7 +410,10 @@ namespace OSHttpServer } m_headers.Add(name, value); break; + */ + case "user-agent": + break; default: m_headers.Add(name, value); break;