aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs
diff options
context:
space:
mode:
authorOren Hurvitz2014-06-01 17:39:11 +0300
committerOren Hurvitz2014-07-21 08:30:03 +0100
commit99ac770abbe3a95887c4b10c82f3985aa878eeef (patch)
tree8c946dab083dd50a352f3861415eca43185d8d95 /OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs
parentSet "[Terrain]SendTerrainUpdatesByViewDistance=true" by default. (diff)
downloadopensim-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 '')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs28
1 files changed, 15 insertions, 13 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs b/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs
index 48ced19..afe052f 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs
@@ -52,23 +52,25 @@ namespace OpenSim.Framework.Servers.HttpServer
52 request.Method = verb; 52 request.Method = verb;
53 request.ContentType = "text/xml"; 53 request.ContentType = "text/xml";
54 54
55 MemoryStream buffer = new MemoryStream(); 55 using (MemoryStream buffer = new MemoryStream())
56 {
57 XmlWriterSettings settings = new XmlWriterSettings();
58 settings.Encoding = Encoding.UTF8;
56 59
57 XmlWriterSettings settings = new XmlWriterSettings(); 60 using (XmlWriter writer = XmlWriter.Create(buffer, settings))
58 settings.Encoding = Encoding.UTF8; 61 {
62 XmlSerializer serializer = new XmlSerializer(type);
63 serializer.Serialize(writer, obj);
64 writer.Flush();
65 }
59 66
60 using (XmlWriter writer = XmlWriter.Create(buffer, settings)) 67 int length = (int)buffer.Length;
61 { 68 request.ContentLength = length;
62 XmlSerializer serializer = new XmlSerializer(type);
63 serializer.Serialize(writer, obj);
64 writer.Flush();
65 }
66 69
67 int length = (int) buffer.Length; 70 using (Stream requestStream = request.GetRequestStream())
68 request.ContentLength = length; 71 requestStream.Write(buffer.ToArray(), 0, length);
72 }
69 73
70 Stream requestStream = request.GetRequestStream();
71 requestStream.Write(buffer.ToArray(), 0, length);
72 // IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); 74 // IAsyncResult result = request.BeginGetResponse(AsyncCallback, request);
73 request.BeginGetResponse(AsyncCallback, request); 75 request.BeginGetResponse(AsyncCallback, request);
74 } 76 }