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/Server/Handlers/Simulation/AgentHandlers.cs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'OpenSim/Server/Handlers/Simulation/AgentHandlers.cs') diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 4ac477f..1254df4 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -232,17 +232,16 @@ namespace OpenSim.Server.Handlers.Simulation httpResponse.KeepAlive = false; Encoding encoding = Encoding.UTF8; - Stream inputStream = null; - if (httpRequest.ContentType == "application/x-gzip") - inputStream = new GZipStream(request, CompressionMode.Decompress); - else if (httpRequest.ContentType == "application/json") - inputStream = request; - else // no go + if (httpRequest.ContentType != "application/json") { httpResponse.StatusCode = 406; return encoding.GetBytes("false"); } + Stream inputStream = request; + if (httpRequest.Headers["Content-Encoding"] == "gzip") + inputStream = new GZipStream(inputStream, CompressionMode.Decompress); + StreamReader reader = new StreamReader(inputStream, encoding); string requestBody = reader.ReadToEnd(); @@ -433,11 +432,9 @@ namespace OpenSim.Server.Handlers.Simulation keysvals.Add("headers", headervals); keysvals.Add("querystringkeys", querystringkeys); - Stream inputStream; - if (httpRequest.ContentType == "application/x-gzip") - inputStream = new GZipStream(request, CompressionMode.Decompress); - else - inputStream = request; + Stream inputStream = request; + if (httpRequest.Headers["Content-Encoding"] == "gzip") + inputStream = new GZipStream(inputStream, CompressionMode.Decompress); Encoding encoding = Encoding.UTF8; StreamReader reader = new StreamReader(inputStream, encoding); -- 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/Server/Handlers/Simulation/AgentHandlers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Server/Handlers/Simulation/AgentHandlers.cs') diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 1254df4..9c7f17e 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -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; -- cgit v1.1