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/Framework/Servers/HttpServer/RestSessionService.cs | |
parent | Set "[Terrain]SendTerrainUpdatesByViewDistance=true" by default. (diff) | |
download | opensim-SC_OLD-99ac770abbe3a95887c4b10c82f3985aa878eeef.zip opensim-SC_OLD-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.gz opensim-SC_OLD-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.bz2 opensim-SC_OLD-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.xz |
Close streams immediately when we finish using them
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/RestSessionService.cs')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/RestSessionService.cs | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs index 83c9848..ad69cd2 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs | |||
@@ -77,25 +77,24 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
77 | request.ContentType = "text/xml"; | 77 | request.ContentType = "text/xml"; |
78 | request.Timeout = 20000; | 78 | request.Timeout = 20000; |
79 | 79 | ||
80 | MemoryStream buffer = new MemoryStream(); | 80 | using (MemoryStream buffer = new MemoryStream()) |
81 | |||
82 | XmlWriterSettings settings = new XmlWriterSettings(); | ||
83 | settings.Encoding = Encoding.UTF8; | ||
84 | |||
85 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | ||
86 | { | 81 | { |
87 | XmlSerializer serializer = new XmlSerializer(type); | 82 | XmlWriterSettings settings = new XmlWriterSettings(); |
88 | serializer.Serialize(writer, sobj); | 83 | settings.Encoding = Encoding.UTF8; |
89 | writer.Flush(); | ||
90 | } | ||
91 | 84 | ||
92 | int length = (int)buffer.Length; | 85 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) |
93 | request.ContentLength = length; | 86 | { |
87 | XmlSerializer serializer = new XmlSerializer(type); | ||
88 | serializer.Serialize(writer, sobj); | ||
89 | writer.Flush(); | ||
90 | } | ||
91 | |||
92 | int length = (int)buffer.Length; | ||
93 | request.ContentLength = length; | ||
94 | 94 | ||
95 | Stream requestStream = request.GetRequestStream(); | 95 | using (Stream requestStream = request.GetRequestStream()) |
96 | requestStream.Write(buffer.ToArray(), 0, length); | 96 | requestStream.Write(buffer.ToArray(), 0, length); |
97 | buffer.Close(); | 97 | } |
98 | requestStream.Close(); | ||
99 | 98 | ||
100 | TResponse deserial = default(TResponse); | 99 | TResponse deserial = default(TResponse); |
101 | using (WebResponse resp = request.GetResponse()) | 100 | using (WebResponse resp = request.GetResponse()) |
@@ -133,25 +132,25 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
133 | request.ContentType = "text/xml"; | 132 | request.ContentType = "text/xml"; |
134 | request.Timeout = 10000; | 133 | request.Timeout = 10000; |
135 | 134 | ||
136 | MemoryStream buffer = new MemoryStream(); | 135 | using (MemoryStream buffer = new MemoryStream()) |
136 | { | ||
137 | XmlWriterSettings settings = new XmlWriterSettings(); | ||
138 | settings.Encoding = Encoding.UTF8; | ||
139 | |||
140 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | ||
141 | { | ||
142 | XmlSerializer serializer = new XmlSerializer(type); | ||
143 | serializer.Serialize(writer, sobj); | ||
144 | writer.Flush(); | ||
145 | } | ||
137 | 146 | ||
138 | XmlWriterSettings settings = new XmlWriterSettings(); | 147 | int length = (int)buffer.Length; |
139 | settings.Encoding = Encoding.UTF8; | 148 | request.ContentLength = length; |
140 | 149 | ||
141 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | 150 | using (Stream requestStream = request.GetRequestStream()) |
142 | { | 151 | requestStream.Write(buffer.ToArray(), 0, length); |
143 | XmlSerializer serializer = new XmlSerializer(type); | ||
144 | serializer.Serialize(writer, sobj); | ||
145 | writer.Flush(); | ||
146 | } | 152 | } |
147 | buffer.Close(); | ||
148 | |||
149 | int length = (int)buffer.Length; | ||
150 | request.ContentLength = length; | ||
151 | 153 | ||
152 | Stream requestStream = request.GetRequestStream(); | ||
153 | requestStream.Write(buffer.ToArray(), 0, length); | ||
154 | requestStream.Close(); | ||
155 | // IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); | 154 | // IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); |
156 | request.BeginGetResponse(AsyncCallback, request); | 155 | request.BeginGetResponse(AsyncCallback, request); |
157 | } | 156 | } |