From b1d8aa0b6418a4edba8ce3b7b6f3db78616fd523 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 25 Mar 2014 16:20:21 +0200 Subject: Use the "Content-Encoding" header to indicate gzipped streams --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 2 +- OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs | 2 +- OpenSim/Framework/WebUtil.cs | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index ea7f195..2f7b549 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -833,7 +833,7 @@ namespace OpenSim.Framework.Servers.HttpServer Stream inputStream = Util.Copy(request.InputStream); - if (request.ContentType == "application/x-gzip") + if (request.Headers["Content-Encoding"] == "gzip") inputStream = new GZipStream(inputStream, System.IO.Compression.CompressionMode.Decompress); using (StreamReader reader = new StreamReader(inputStream, Encoding.UTF8)) diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs index 3171759..f36cbbc 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs @@ -181,7 +181,7 @@ namespace OpenSim.Framework.Servers.HttpServer _request = req; _context = context; - if (null != req.Headers["content-encoding"]) + if ((null != req.Headers["content-encoding"]) && ("gzip" != req.Headers["content-encoding"])) _contentEncoding = Encoding.GetEncoding(_request.Headers["content-encoding"]); if (null != req.Headers["content-type"]) _contentType = _request.Headers["content-type"]; diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 10a2560..3972c06 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -250,9 +250,12 @@ namespace OpenSim.Framework byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); + request.ContentType = "application/json"; + if (compressed) { - request.ContentType = "application/x-gzip"; + request.Headers["Content-Encoding"] = "gzip"; + using (MemoryStream ms = new MemoryStream()) { using (GZipStream comp = new GZipStream(ms, CompressionMode.Compress)) @@ -270,10 +273,9 @@ namespace OpenSim.Framework } else { - request.ContentType = "application/json"; request.ContentLength = buffer.Length; //Count bytes to send using (Stream requestStream = request.GetRequestStream()) - requestStream.Write(buffer, 0, buffer.Length); //Send it + requestStream.Write(buffer, 0, buffer.Length); //Send it } } -- cgit v1.1 From 6d1d58b6549daea0183b70a1c702e3017abb9663 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 25 Mar 2014 19:09:03 +0200 Subject: Use the "X-Content-Encoding" header to indicate gzipped data, because old OpenSims fail if they get an unknown "Content-Encoding" --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 5 ++++- OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs | 15 +++++++++++++-- OpenSim/Framework/WebUtil.cs | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 2f7b549..28324a5 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -833,7 +833,7 @@ namespace OpenSim.Framework.Servers.HttpServer Stream inputStream = Util.Copy(request.InputStream); - if (request.Headers["Content-Encoding"] == "gzip") + if ((request.Headers["Content-Encoding"] == "gzip") || (request.Headers["X-Content-Encoding"] == "gzip")) inputStream = new GZipStream(inputStream, System.IO.Compression.CompressionMode.Decompress); using (StreamReader reader = new StreamReader(inputStream, Encoding.UTF8)) @@ -978,6 +978,9 @@ namespace OpenSim.Framework.Servers.HttpServer { Stream requestStream = request.InputStream; + if ((request.Headers["Content-Encoding"] == "gzip") || (request.Headers["X-Content-Encoding"] == "gzip")) + requestStream = new GZipStream(requestStream, System.IO.Compression.CompressionMode.Decompress); + Encoding encoding = Encoding.UTF8; StreamReader reader = new StreamReader(requestStream, encoding); diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs index f36cbbc..05ec6dc 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs @@ -181,12 +181,23 @@ namespace OpenSim.Framework.Servers.HttpServer _request = req; _context = context; - if ((null != req.Headers["content-encoding"]) && ("gzip" != req.Headers["content-encoding"])) - _contentEncoding = Encoding.GetEncoding(_request.Headers["content-encoding"]); + if (null != req.Headers["content-encoding"]) + { + try + { + _contentEncoding = Encoding.GetEncoding(_request.Headers["content-encoding"]); + } + catch (Exception) + { + // ignore + } + } + if (null != req.Headers["content-type"]) _contentType = _request.Headers["content-type"]; if (null != req.Headers["user-agent"]) _userAgent = req.Headers["user-agent"]; + if (null != req.Headers["remote_addr"]) { try diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 3972c06..eb3633a 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -254,7 +254,7 @@ namespace OpenSim.Framework if (compressed) { - request.Headers["Content-Encoding"] = "gzip"; + request.Headers["X-Content-Encoding"] = "gzip"; // can't set "Content-Encoding" because old OpenSims fail if they get an unrecognized Content-Encoding using (MemoryStream ms = new MemoryStream()) { -- cgit v1.1 From 7a47c15edbbebd93fc3355dfed68c2d5f635c897 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Wed, 26 Mar 2014 21:31:16 +0200 Subject: - Increased the threadpool timeout to 10 minutes - Changed a few places that launch long-lasting threads to skip the timeout altogether --- OpenSim/Framework/Util.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index ce4af8b..c7a7341 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -2031,7 +2031,7 @@ namespace OpenSim.Framework // Maps (ThreadFunc number -> Thread) private static ConcurrentDictionary activeThreads = new ConcurrentDictionary(); - private static readonly int THREAD_TIMEOUT = 60 * 1000; + private static readonly int THREAD_TIMEOUT = 10 * 60 * 1000; // 10 minutes /// /// Finds threads in the main thread pool that have timed-out, and aborts them. -- cgit v1.1 From b0bae62c30323ed42a68de341998e5dc722bb199 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 26 Mar 2014 20:58:58 +0000 Subject: refactor: Actually use MaptileStaticFile in RegionInfo rather than having both a public field and a get property --- OpenSim/Framework/RegionInfo.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index f71ee86..2390118 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -143,7 +143,6 @@ namespace OpenSim.Framework public string RemotingAddress; public UUID ScopeID = UUID.Zero; private UUID m_maptileStaticUUID = UUID.Zero; - public string m_maptileStaticFile; public uint WorldLocX = 0; public uint WorldLocY = 0; @@ -351,10 +350,7 @@ namespace OpenSim.Framework get { return m_maptileStaticUUID; } } - public string MaptileStaticFile - { - get { return m_maptileStaticFile; } - } + public string MaptileStaticFile { get; private set; } /// /// The port by which http communication occurs with the region (most noticeably, CAPS communication) @@ -723,7 +719,7 @@ namespace OpenSim.Framework config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString()); } - m_maptileStaticFile = config.GetString("MaptileStaticFile", String.Empty); + MaptileStaticFile = config.GetString("MaptileStaticFile", String.Empty); allKeys.Remove("MaptileStaticFile"); #endregion @@ -853,8 +849,8 @@ namespace OpenSim.Framework if (m_maptileStaticUUID != UUID.Zero) config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString()); - if (m_maptileStaticFile != String.Empty) - config.Set("MaptileStaticFile", m_maptileStaticFile); + if (MaptileStaticFile != String.Empty) + config.Set("MaptileStaticFile", MaptileStaticFile); } public bool ignoreIncomingConfiguration(string configuration_key, object configuration_result) @@ -966,7 +962,7 @@ namespace OpenSim.Framework "UUID of a texture to use as the map for this region", m_maptileStaticUUID.ToString(), true); configMember.addConfigurationOption("region_static_mapfile", ConfigurationOption.ConfigurationTypes.TYPE_STRING, - "Filename of a texture to use as the map for this region", m_maptileStaticFile, true); + "Filename of a texture to use as the map for this region", MaptileStaticFile, true); } public void loadConfigurationOptions() @@ -1116,7 +1112,7 @@ namespace OpenSim.Framework m_maptileStaticUUID = (UUID)configuration_result; break; case "region_static_mapfile": - m_maptileStaticFile = (string)configuration_result; + MaptileStaticFile = (string)configuration_result; break; } -- cgit v1.1 From 76add0fdb0b7b5c0e93c21371c8a4efa3ad2f7e4 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 27 Mar 2014 09:43:03 +0200 Subject: Log errors in MakeRequest() as INFO, not ERROR. Some communications problems are benign (e.g., can't send Friend status update to a region that is down), so don't log them as ERROR so soon. We rethrow the exception, so the caller can still decide to log the error as an ERROR. Resolves http://opensimulator.org/mantis/view.php?id=7077 --- OpenSim/Framework/WebUtil.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index eb3633a..89181a9 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -1026,7 +1026,7 @@ namespace OpenSim.Framework } catch (Exception e) { - m_log.ErrorFormat("[FORMS]: Error sending request to {0}: {1}. Request: {2}", requestUrl, e.Message, + m_log.InfoFormat("[FORMS]: Error sending request to {0}: {1}. Request: {2}", requestUrl, e.Message, obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); throw e; } @@ -1054,7 +1054,7 @@ namespace OpenSim.Framework } catch (Exception e) { - m_log.ErrorFormat("[FORMS]: Error receiving response from {0}: {1}. Request: {2}", requestUrl, e.Message, + m_log.InfoFormat("[FORMS]: Error receiving response from {0}: {1}. Request: {2}", requestUrl, e.Message, obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); throw e; } -- cgit v1.1