diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs index 3f72c31af2..6c0aa46ce8 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs @@ -88,6 +88,7 @@ namespace OpenSim.Framework.Servers.HttpServer serializer.Serialize(writer, sobj); writer.Flush(); } + buffer.Close(); int length = (int)buffer.Length; request.ContentLength = length; @@ -99,8 +100,19 @@ namespace OpenSim.Framework.Servers.HttpServer using (WebResponse resp = request.GetResponse()) { XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); - deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); - resp.Close(); + Stream respStream = null; + try + { + respStream = resp.GetResponseStream(); + deserial = (TResponse)deserializer.Deserialize(respStream); + } + catch { } + finally + { + if (respStream != null) + respStream.Close(); + resp.Close(); + } } return deserial; } @@ -140,6 +152,7 @@ namespace OpenSim.Framework.Servers.HttpServer serializer.Serialize(writer, sobj); writer.Flush(); } + buffer.Close(); int length = (int)buffer.Length; request.ContentLength = length; @@ -165,6 +178,8 @@ namespace OpenSim.Framework.Servers.HttpServer // m_log.DebugFormat("[REST OBJECT POSTER RESPONSE]: Received {0}", reader.ReadToEnd()); deserial = (TResponse)deserializer.Deserialize(stream); + if (stream != null) + stream.Close(); if (deserial != null && ResponseCallback != null) { diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs index 85622a17eb..e76d80e6c9 100644 --- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs +++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs @@ -62,6 +62,7 @@ namespace OpenSim.Framework.Servers.HttpServer writer.Write(obj); writer.Flush(); } + buffer.Close(); length = (int)obj.Length; request.ContentLength = length;