aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer
diff options
context:
space:
mode:
authorDiva Canto2009-10-02 20:35:15 -0700
committerDiva Canto2009-10-02 20:35:15 -0700
commit006dfd6d9a31127b5aad55b16b7f85f29faff620 (patch)
tree9b422ca9c8a749cf0f62b418a7009ae7a53b0d4b /OpenSim/Framework/Servers/HttpServer
parent* Creates Util.UTF8 and switches some references of Encoding.UTF8 to Util.UTF... (diff)
downloadopensim-SC_OLD-006dfd6d9a31127b5aad55b16b7f85f29faff620.zip
opensim-SC_OLD-006dfd6d9a31127b5aad55b16b7f85f29faff620.tar.gz
opensim-SC_OLD-006dfd6d9a31127b5aad55b16b7f85f29faff620.tar.bz2
opensim-SC_OLD-006dfd6d9a31127b5aad55b16b7f85f29faff620.tar.xz
Closing another stream.
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs23
1 files changed, 19 insertions, 4 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
index ec9bd4f..eab463c 100644
--- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
+++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
@@ -58,6 +58,7 @@ namespace OpenSim.Framework.Servers.HttpServer
58 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj) 58 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj)
59 { 59 {
60 Type type = typeof (TRequest); 60 Type type = typeof (TRequest);
61 TResponse deserial = default(TResponse);
61 62
62 WebRequest request = WebRequest.Create(requestUrl); 63 WebRequest request = WebRequest.Create(requestUrl);
63 request.Method = verb; 64 request.Method = verb;
@@ -81,19 +82,33 @@ namespace OpenSim.Framework.Servers.HttpServer
81 int length = (int) buffer.Length; 82 int length = (int) buffer.Length;
82 request.ContentLength = length; 83 request.ContentLength = length;
83 84
84 Stream requestStream = request.GetRequestStream(); 85 Stream requestStream = null;
85 requestStream.Write(buffer.ToArray(), 0, length); 86 try
87 {
88 requestStream = request.GetRequestStream();
89 requestStream.Write(buffer.ToArray(), 0, length);
90 }
91 catch (Exception)
92 {
93 return deserial;
94 }
95 finally
96 {
97 if (requestStream != null)
98 requestStream.Close();
99 }
86 } 100 }
87 101
88 TResponse deserial = default(TResponse);
89 try 102 try
90 { 103 {
91 using (WebResponse resp = request.GetResponse()) 104 using (WebResponse resp = request.GetResponse())
92 { 105 {
93 if (resp.ContentLength > 0) 106 if (resp.ContentLength > 0)
94 { 107 {
108 Stream respStream = resp.GetResponseStream();
95 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); 109 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
96 deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); 110 deserial = (TResponse)deserializer.Deserialize(respStream);
111 respStream.Close();
97 } 112 }
98 } 113 }
99 } 114 }