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/RestObjectPosterResponse.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/Framework/Servers/HttpServer/RestObjectPosterResponse.cs')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs b/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs index 451745c..a911b9f 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs | |||
@@ -60,24 +60,25 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
60 | request.ContentType = "text/xml"; | 60 | request.ContentType = "text/xml"; |
61 | request.Timeout = 10000; | 61 | request.Timeout = 10000; |
62 | 62 | ||
63 | MemoryStream buffer = new MemoryStream(); | 63 | using (MemoryStream buffer = new MemoryStream()) |
64 | { | ||
65 | XmlWriterSettings settings = new XmlWriterSettings(); | ||
66 | settings.Encoding = Encoding.UTF8; | ||
67 | |||
68 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | ||
69 | { | ||
70 | XmlSerializer serializer = new XmlSerializer(type); | ||
71 | serializer.Serialize(writer, obj); | ||
72 | writer.Flush(); | ||
73 | } | ||
64 | 74 | ||
65 | XmlWriterSettings settings = new XmlWriterSettings(); | 75 | int length = (int)buffer.Length; |
66 | settings.Encoding = Encoding.UTF8; | 76 | request.ContentLength = length; |
67 | 77 | ||
68 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | 78 | using (Stream requestStream = request.GetRequestStream()) |
69 | { | 79 | requestStream.Write(buffer.ToArray(), 0, length); |
70 | XmlSerializer serializer = new XmlSerializer(type); | ||
71 | serializer.Serialize(writer, obj); | ||
72 | writer.Flush(); | ||
73 | } | 80 | } |
74 | 81 | ||
75 | int length = (int) buffer.Length; | ||
76 | request.ContentLength = length; | ||
77 | |||
78 | Stream requestStream = request.GetRequestStream(); | ||
79 | requestStream.Write(buffer.ToArray(), 0, length); | ||
80 | requestStream.Close(); | ||
81 | // IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); | 82 | // IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); |
82 | request.BeginGetResponse(AsyncCallback, request); | 83 | request.BeginGetResponse(AsyncCallback, request); |
83 | } | 84 | } |