From eae9928961cea84a2dd95ab59cdb3d5a328dcfc7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 25 Apr 2020 13:45:45 +0100 Subject: [PATCH] null method is already checked at low level, remove optional status 500 message --- .../Servers/HttpServer/BaseHttpServer.cs | 52 +------------------ .../HttpServer/Interfaces/IHttpServer.cs | 2 - bin/http_500.html.example | 1 - 3 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 bin/http_500.html.example diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 1d975ac932..afe4b1e109 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -542,7 +542,6 @@ namespace OpenSim.Framework.Servers.HttpServer { IHttpClientContext context = (IHttpClientContext)source; IHttpRequest request = args.Request; - if (TryGetPollServiceHTTPHandler(request.UriPath, out PollServiceEventArgs psEvArgs)) { psEvArgs.RequestsReceived++; @@ -587,23 +586,6 @@ namespace OpenSim.Framework.Servers.HttpServer /// public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response) { - if (request.HttpMethod == String.Empty) // Can't handle empty requests, not wasting a thread - { - try - { - if(request.InputStream != null && request.InputStream.CanRead) - request.InputStream.Close(); - byte[] buffer500 = SendHTML500(response); - response.OutputStream.Write(buffer500, 0, buffer500.Length); - response.Send(); - } - catch - { - } - - return; - } - string requestMethod = request.HttpMethod; string uriString = request.RawUrl; @@ -850,8 +832,7 @@ namespace OpenSim.Framework.Servers.HttpServer m_log.Error("[BASE HTTP SERVER]: HandleRequest() threw exception ", e); try { - byte[] buffer500 = SendHTML500(response); - response.OutputStream.Write(buffer500, 0, buffer500.Length); + response.StatusCode =(int)HttpStatusCode.InternalServerError; response.Send(); } catch @@ -1980,21 +1961,6 @@ namespace OpenSim.Framework.Servers.HttpServer return buffer; } - public byte[] SendHTML500(OSHttpResponse response) - { - // I know this statuscode is dumb, but the client doesn't respond to 404s and 500s - response.StatusCode = (int)HttpStatusCode.OK; - response.AddHeader("Content-type", "text/html"); - - string responseString = GetHTTP500(); - byte[] buffer = Encoding.UTF8.GetBytes(responseString); - - response.ContentLength64 = buffer.Length; - response.ContentEncoding = Encoding.UTF8; - - return buffer; - } - public void Start() { Start(true, true); @@ -2232,27 +2198,11 @@ namespace OpenSim.Framework.Servers.HttpServer return result; } - public string GetHTTP500() - { - string file = Path.Combine(".", "http_500.html"); - if (!File.Exists(file)) - return getDefaultHTTP500(); - string result; - using(StreamReader sr = File.OpenText(file)) - result = sr.ReadToEnd(); - return result; - } - // Fallback HTTP responses in case the HTTP error response files don't exist private static string getDefaultHTTP404(string host) { return "404 Page not found

Ooops!

The page you requested has been obsconded with by knomes. Find hippos quick!

If you are trying to log-in, your link parameters should have: "-loginpage http://" + host + "/?method=login -loginuri http://" + host + "/" in your link

"; } - - private static string getDefaultHTTP500() - { - return "500 Internal Server Error

Ooops!

The server you requested is overun by knomes! Find hippos quick!

"; - } } public class HttpServerContextObj diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs index 29dcf1a4c0..2f1459e5a0 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs @@ -149,7 +149,5 @@ namespace OpenSim.Framework.Servers.HttpServer void RemoveJsonRPCHandler(string method); string GetHTTP404(string host); - - string GetHTTP500(); } } diff --git a/bin/http_500.html.example b/bin/http_500.html.example deleted file mode 100644 index 6b5402d9d9..0000000000 --- a/bin/http_500.html.example +++ /dev/null @@ -1 +0,0 @@ -500 Internal Server Error

Ooops!

The server you requested is overun by knomes! Find hippos quick!

\ No newline at end of file