diff options
author | Oren Hurvitz | 2014-06-01 17:39:11 +0300 |
---|---|---|
committer | Oren Hurvitz | 2014-07-21 08:30:03 +0100 |
commit | 99ac770abbe3a95887c4b10c82f3985aa878eeef (patch) | |
tree | 8c946dab083dd50a352f3861415eca43185d8d95 /OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |
parent | Set "[Terrain]SendTerrainUpdatesByViewDistance=true" by default. (diff) | |
download | opensim-SC-99ac770abbe3a95887c4b10c82f3985aa878eeef.zip opensim-SC-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.gz opensim-SC-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.bz2 opensim-SC-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.xz |
Close streams immediately when we finish using them
Diffstat (limited to 'OpenSim/Server/Handlers/Simulation/AgentHandlers.cs')
-rw-r--r-- | OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 6d3a3a7..da2bfeb 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |||
@@ -250,14 +250,30 @@ namespace OpenSim.Server.Handlers.Simulation | |||
250 | return encoding.GetBytes("false"); | 250 | return encoding.GetBytes("false"); |
251 | } | 251 | } |
252 | 252 | ||
253 | string requestBody; | ||
254 | |||
253 | Stream inputStream = request; | 255 | Stream inputStream = request; |
254 | if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) | 256 | Stream innerStream = null; |
255 | inputStream = new GZipStream(inputStream, CompressionMode.Decompress); | 257 | try |
258 | { | ||
259 | if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) | ||
260 | { | ||
261 | innerStream = inputStream; | ||
262 | inputStream = new GZipStream(innerStream, CompressionMode.Decompress); | ||
263 | } | ||
256 | 264 | ||
257 | StreamReader reader = new StreamReader(inputStream, encoding); | 265 | using (StreamReader reader = new StreamReader(inputStream, encoding)) |
266 | { | ||
267 | requestBody = reader.ReadToEnd(); | ||
268 | } | ||
269 | } | ||
270 | finally | ||
271 | { | ||
272 | if (innerStream != null) | ||
273 | innerStream.Dispose(); | ||
274 | inputStream.Dispose(); | ||
275 | } | ||
258 | 276 | ||
259 | string requestBody = reader.ReadToEnd(); | ||
260 | reader.Close(); | ||
261 | keysvals.Add("body", requestBody); | 277 | keysvals.Add("body", requestBody); |
262 | 278 | ||
263 | Hashtable responsedata = new Hashtable(); | 279 | Hashtable responsedata = new Hashtable(); |
@@ -461,15 +477,31 @@ namespace OpenSim.Server.Handlers.Simulation | |||
461 | keysvals.Add("headers", headervals); | 477 | keysvals.Add("headers", headervals); |
462 | keysvals.Add("querystringkeys", querystringkeys); | 478 | keysvals.Add("querystringkeys", querystringkeys); |
463 | 479 | ||
480 | String requestBody; | ||
481 | Encoding encoding = Encoding.UTF8; | ||
482 | |||
464 | Stream inputStream = request; | 483 | Stream inputStream = request; |
465 | if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) | 484 | Stream innerStream = null; |
466 | inputStream = new GZipStream(inputStream, CompressionMode.Decompress); | 485 | try |
486 | { | ||
487 | if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) | ||
488 | { | ||
489 | innerStream = inputStream; | ||
490 | inputStream = new GZipStream(innerStream, CompressionMode.Decompress); | ||
491 | } | ||
467 | 492 | ||
468 | Encoding encoding = Encoding.UTF8; | 493 | using (StreamReader reader = new StreamReader(inputStream, encoding)) |
469 | StreamReader reader = new StreamReader(inputStream, encoding); | 494 | { |
495 | requestBody = reader.ReadToEnd(); | ||
496 | } | ||
497 | } | ||
498 | finally | ||
499 | { | ||
500 | if (innerStream != null) | ||
501 | innerStream.Dispose(); | ||
502 | inputStream.Dispose(); | ||
503 | } | ||
470 | 504 | ||
471 | string requestBody = reader.ReadToEnd(); | ||
472 | reader.Close(); | ||
473 | keysvals.Add("body", requestBody); | 505 | keysvals.Add("body", requestBody); |
474 | 506 | ||
475 | httpResponse.StatusCode = 200; | 507 | httpResponse.StatusCode = 200; |