Use the "X-Content-Encoding" header to indicate gzipped data, because old OpenSims fail if they get an unknown "Content-Encoding"

0.8.0.3
Oren Hurvitz 2014-03-25 19:09:03 +02:00
parent b1d8aa0b64
commit 6d1d58b654
4 changed files with 20 additions and 6 deletions

View File

@ -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);

View File

@ -181,12 +181,23 @@ namespace OpenSim.Framework.Servers.HttpServer
_request = req;
_context = context;
if ((null != req.Headers["content-encoding"]) && ("gzip" != req.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

View File

@ -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())
{

View File

@ -239,7 +239,7 @@ namespace OpenSim.Server.Handlers.Simulation
}
Stream inputStream = request;
if (httpRequest.Headers["Content-Encoding"] == "gzip")
if ((httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip"))
inputStream = new GZipStream(inputStream, CompressionMode.Decompress);
StreamReader reader = new StreamReader(inputStream, encoding);
@ -433,7 +433,7 @@ namespace OpenSim.Server.Handlers.Simulation
keysvals.Add("querystringkeys", querystringkeys);
Stream inputStream = request;
if (httpRequest.Headers["Content-Encoding"] == "gzip")
if ((httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip"))
inputStream = new GZipStream(inputStream, CompressionMode.Decompress);
Encoding encoding = Encoding.UTF8;