aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorOren Hurvitz2014-03-25 16:20:21 +0200
committerOren Hurvitz2014-03-25 15:36:59 +0100
commitb1d8aa0b6418a4edba8ce3b7b6f3db78616fd523 (patch)
treecddba93c37103619e422f1d6c062fcea03c24e22 /OpenSim
parentUse log-rolling on the log files (once per day) (diff)
downloadopensim-SC_OLD-b1d8aa0b6418a4edba8ce3b7b6f3db78616fd523.zip
opensim-SC_OLD-b1d8aa0b6418a4edba8ce3b7b6f3db78616fd523.tar.gz
opensim-SC_OLD-b1d8aa0b6418a4edba8ce3b7b6f3db78616fd523.tar.bz2
opensim-SC_OLD-b1d8aa0b6418a4edba8ce3b7b6f3db78616fd523.tar.xz
Use the "Content-Encoding" header to indicate gzipped streams
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs2
-rw-r--r--OpenSim/Framework/WebUtil.cs8
-rw-r--r--OpenSim/Server/Handlers/Simulation/AgentHandlers.cs19
4 files changed, 15 insertions, 16 deletions
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
833 833
834 Stream inputStream = Util.Copy(request.InputStream); 834 Stream inputStream = Util.Copy(request.InputStream);
835 835
836 if (request.ContentType == "application/x-gzip") 836 if (request.Headers["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))
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
181 _request = req; 181 _request = req;
182 _context = context; 182 _context = context;
183 183
184 if (null != req.Headers["content-encoding"]) 184 if ((null != req.Headers["content-encoding"]) && ("gzip" != req.Headers["content-encoding"]))
185 _contentEncoding = Encoding.GetEncoding(_request.Headers["content-encoding"]); 185 _contentEncoding = Encoding.GetEncoding(_request.Headers["content-encoding"]);
186 if (null != req.Headers["content-type"]) 186 if (null != req.Headers["content-type"])
187 _contentType = _request.Headers["content-type"]; 187 _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
250 250
251 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); 251 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer);
252 252
253 request.ContentType = "application/json";
254
253 if (compressed) 255 if (compressed)
254 { 256 {
255 request.ContentType = "application/x-gzip"; 257 request.Headers["Content-Encoding"] = "gzip";
258
256 using (MemoryStream ms = new MemoryStream()) 259 using (MemoryStream ms = new MemoryStream())
257 { 260 {
258 using (GZipStream comp = new GZipStream(ms, CompressionMode.Compress)) 261 using (GZipStream comp = new GZipStream(ms, CompressionMode.Compress))
@@ -270,10 +273,9 @@ namespace OpenSim.Framework
270 } 273 }
271 else 274 else
272 { 275 {
273 request.ContentType = "application/json";
274 request.ContentLength = buffer.Length; //Count bytes to send 276 request.ContentLength = buffer.Length; //Count bytes to send
275 using (Stream requestStream = request.GetRequestStream()) 277 using (Stream requestStream = request.GetRequestStream())
276 requestStream.Write(buffer, 0, buffer.Length); //Send it 278 requestStream.Write(buffer, 0, buffer.Length); //Send it
277 } 279 }
278 } 280 }
279 281
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
232 httpResponse.KeepAlive = false; 232 httpResponse.KeepAlive = false;
233 Encoding encoding = Encoding.UTF8; 233 Encoding encoding = Encoding.UTF8;
234 234
235 Stream inputStream = null; 235 if (httpRequest.ContentType != "application/json")
236 if (httpRequest.ContentType == "application/x-gzip")
237 inputStream = new GZipStream(request, CompressionMode.Decompress);
238 else if (httpRequest.ContentType == "application/json")
239 inputStream = request;
240 else // no go
241 { 236 {
242 httpResponse.StatusCode = 406; 237 httpResponse.StatusCode = 406;
243 return encoding.GetBytes("false"); 238 return encoding.GetBytes("false");
244 } 239 }
245 240
241 Stream inputStream = request;
242 if (httpRequest.Headers["Content-Encoding"] == "gzip")
243 inputStream = new GZipStream(inputStream, CompressionMode.Decompress);
244
246 StreamReader reader = new StreamReader(inputStream, encoding); 245 StreamReader reader = new StreamReader(inputStream, encoding);
247 246
248 string requestBody = reader.ReadToEnd(); 247 string requestBody = reader.ReadToEnd();
@@ -433,11 +432,9 @@ namespace OpenSim.Server.Handlers.Simulation
433 keysvals.Add("headers", headervals); 432 keysvals.Add("headers", headervals);
434 keysvals.Add("querystringkeys", querystringkeys); 433 keysvals.Add("querystringkeys", querystringkeys);
435 434
436 Stream inputStream; 435 Stream inputStream = request;
437 if (httpRequest.ContentType == "application/x-gzip") 436 if (httpRequest.Headers["Content-Encoding"] == "gzip")
438 inputStream = new GZipStream(request, CompressionMode.Decompress); 437 inputStream = new GZipStream(inputStream, CompressionMode.Decompress);
439 else
440 inputStream = request;
441 438
442 Encoding encoding = Encoding.UTF8; 439 Encoding encoding = Encoding.UTF8;
443 StreamReader reader = new StreamReader(inputStream, encoding); 440 StreamReader reader = new StreamReader(inputStream, encoding);