diff options
author | Oren Hurvitz | 2014-06-01 17:39:11 +0300 |
---|---|---|
committer | Justin Clark-Casey | 2014-08-02 00:55:57 +0100 |
commit | e41e52e09727842d990a31e2a5f7f3e9c88fe8b3 (patch) | |
tree | 5779c9f42cd913f63e2d237b5a407214933585db /OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |
parent | Add code to GridService to check for overlapping of varregions (diff) | |
download | opensim-SC_OLD-e41e52e09727842d990a31e2a5f7f3e9c88fe8b3.zip opensim-SC_OLD-e41e52e09727842d990a31e2a5f7f3e9c88fe8b3.tar.gz opensim-SC_OLD-e41e52e09727842d990a31e2a5f7f3e9c88fe8b3.tar.bz2 opensim-SC_OLD-e41e52e09727842d990a31e2a5f7f3e9c88fe8b3.tar.xz |
Close streams immediately when we finish using them
Diffstat (limited to '')
-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; |