From 70d2878d0a860dce75c79103c2c2eacddc2736bb Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 25 Apr 2020 21:13:54 +0100 Subject: [PATCH] simplify default 404 message, removing wrong(missing) host info --- .../Servers/HttpServer/BaseHttpServer.cs | 21 +++++++------------ .../HttpServer/Interfaces/IHttpServer.cs | 2 +- .../UserStatistics/WebStatsModule.cs | 2 +- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index e0fbea2090..c0e715d20f 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -1718,11 +1718,6 @@ namespace OpenSim.Framework.Servers.HttpServer headervals[headername] = request.Headers[headername]; } - if (headervals.Contains("Host")) - { - host = (string)headervals["Host"]; - } - keysvals.Add("headers", headervals); keysvals.Add("querystringkeys", querystringkeys); keysvals.Add("requestvars", requestVars); @@ -1745,7 +1740,7 @@ namespace OpenSim.Framework.Servers.HttpServer else { // m_log.Warn("[BASE HTTP SERVER]: Handler Not Found"); - buffer = SendHTML404(response, host); + buffer = SendHTML404(response); } } else @@ -1762,7 +1757,7 @@ namespace OpenSim.Framework.Servers.HttpServer else { // m_log.Warn("[BASE HTTP SERVER]: Handler Not Found2"); - buffer = SendHTML404(response, host); + buffer = SendHTML404(response); } } @@ -1946,12 +1941,12 @@ namespace OpenSim.Framework.Servers.HttpServer return buffer; } - public byte[] SendHTML404(OSHttpResponse response, string host) + public byte[] SendHTML404(OSHttpResponse response) { response.StatusCode = 404; response.ContentType = "text/html"; - string responseString = GetHTTP404(host); + string responseString = GetHTTP404(); byte[] buffer = Encoding.UTF8.GetBytes(responseString); response.ContentLength64 = buffer.Length; @@ -2185,11 +2180,11 @@ namespace OpenSim.Framework.Servers.HttpServer return false; } - public string GetHTTP404(string host) + public string GetHTTP404() { string file = Path.Combine(".", "http_404.html"); if (!File.Exists(file)) - return getDefaultHTTP404(host); + return getDefaultHTTP404(); StreamReader sr = File.OpenText(file); string result = sr.ReadToEnd(); @@ -2198,9 +2193,9 @@ namespace OpenSim.Framework.Servers.HttpServer } // Fallback HTTP responses in case the HTTP error response files don't exist - private static string getDefaultHTTP404(string host) + private static string getDefaultHTTP404() { - 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

"; + return "404 Page not found

Ooops!

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

"; } } diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs index 2f1459e5a0..6f1379e843 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs @@ -148,6 +148,6 @@ namespace OpenSim.Framework.Servers.HttpServer void RemoveJsonRPCHandler(string method); - string GetHTTP404(string host); + string GetHTTP404(); } } diff --git a/OpenSim/Region/OptionalModules/UserStatistics/WebStatsModule.cs b/OpenSim/Region/OptionalModules/UserStatistics/WebStatsModule.cs index c15b194852..4046efe877 100644 --- a/OpenSim/Region/OptionalModules/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/OptionalModules/UserStatistics/WebStatsModule.cs @@ -317,7 +317,7 @@ namespace OpenSim.Region.UserStatistics } else { - strOut = MainServer.Instance.GetHTTP404(""); + strOut = MainServer.Instance.GetHTTP404(); } responsedata["int_response_code"] = response_code;