diff options
author | Oren Hurvitz | 2014-03-25 19:09:03 +0200 |
---|---|---|
committer | Oren Hurvitz | 2014-03-25 18:09:23 +0100 |
commit | 6d1d58b6549daea0183b70a1c702e3017abb9663 (patch) | |
tree | 3bd5ce0ff0f501dcccccc24915b7e00207563d47 /OpenSim/Framework | |
parent | Use the "Content-Encoding" header to indicate gzipped streams (diff) | |
download | opensim-SC-6d1d58b6549daea0183b70a1c702e3017abb9663.zip opensim-SC-6d1d58b6549daea0183b70a1c702e3017abb9663.tar.gz opensim-SC-6d1d58b6549daea0183b70a1c702e3017abb9663.tar.bz2 opensim-SC-6d1d58b6549daea0183b70a1c702e3017abb9663.tar.xz |
Use the "X-Content-Encoding" header to indicate gzipped data, because old OpenSims fail if they get an unknown "Content-Encoding"
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 5 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs | 15 | ||||
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 2 |
3 files changed, 18 insertions, 4 deletions
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 | |||
833 | 833 | ||
834 | Stream inputStream = Util.Copy(request.InputStream); | 834 | Stream inputStream = Util.Copy(request.InputStream); |
835 | 835 | ||
836 | if (request.Headers["Content-Encoding"] == "gzip") | 836 | if ((request.Headers["Content-Encoding"] == "gzip") || (request.Headers["X-Content-Encoding"] == "gzip")) |
837 | inputStream = new GZipStream(inputStream, System.IO.Compression.CompressionMode.Decompress); | 837 | inputStream = new GZipStream(inputStream, System.IO.Compression.CompressionMode.Decompress); |
838 | 838 | ||
839 | using (StreamReader reader = new StreamReader(inputStream, Encoding.UTF8)) | 839 | using (StreamReader reader = new StreamReader(inputStream, Encoding.UTF8)) |
@@ -978,6 +978,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
978 | { | 978 | { |
979 | Stream requestStream = request.InputStream; | 979 | Stream requestStream = request.InputStream; |
980 | 980 | ||
981 | if ((request.Headers["Content-Encoding"] == "gzip") || (request.Headers["X-Content-Encoding"] == "gzip")) | ||
982 | requestStream = new GZipStream(requestStream, System.IO.Compression.CompressionMode.Decompress); | ||
983 | |||
981 | Encoding encoding = Encoding.UTF8; | 984 | Encoding encoding = Encoding.UTF8; |
982 | StreamReader reader = new StreamReader(requestStream, encoding); | 985 | StreamReader reader = new StreamReader(requestStream, encoding); |
983 | 986 | ||
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 | |||
181 | _request = req; | 181 | _request = req; |
182 | _context = context; | 182 | _context = context; |
183 | 183 | ||
184 | if ((null != req.Headers["content-encoding"]) && ("gzip" != req.Headers["content-encoding"])) | 184 | if (null != req.Headers["content-encoding"]) |
185 | _contentEncoding = Encoding.GetEncoding(_request.Headers["content-encoding"]); | 185 | { |
186 | try | ||
187 | { | ||
188 | _contentEncoding = Encoding.GetEncoding(_request.Headers["content-encoding"]); | ||
189 | } | ||
190 | catch (Exception) | ||
191 | { | ||
192 | // ignore | ||
193 | } | ||
194 | } | ||
195 | |||
186 | if (null != req.Headers["content-type"]) | 196 | if (null != req.Headers["content-type"]) |
187 | _contentType = _request.Headers["content-type"]; | 197 | _contentType = _request.Headers["content-type"]; |
188 | if (null != req.Headers["user-agent"]) | 198 | if (null != req.Headers["user-agent"]) |
189 | _userAgent = req.Headers["user-agent"]; | 199 | _userAgent = req.Headers["user-agent"]; |
200 | |||
190 | if (null != req.Headers["remote_addr"]) | 201 | if (null != req.Headers["remote_addr"]) |
191 | { | 202 | { |
192 | try | 203 | 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 | |||
254 | 254 | ||
255 | if (compressed) | 255 | if (compressed) |
256 | { | 256 | { |
257 | request.Headers["Content-Encoding"] = "gzip"; | 257 | request.Headers["X-Content-Encoding"] = "gzip"; // can't set "Content-Encoding" because old OpenSims fail if they get an unrecognized Content-Encoding |
258 | 258 | ||
259 | using (MemoryStream ms = new MemoryStream()) | 259 | using (MemoryStream ms = new MemoryStream()) |
260 | { | 260 | { |