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 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Servers/HttpServer') 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"]; -- 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 +++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Servers/HttpServer') 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 -- cgit v1.1