aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs30
1 files changed, 24 insertions, 6 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs
index 5afa110..03c12dd 100644
--- a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs
+++ b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs
@@ -91,24 +91,35 @@ namespace OpenSim.Framework.Servers.HttpServer
91 Stream requestStream = request.EndGetRequestStream(res); 91 Stream requestStream = request.EndGetRequestStream(res);
92 92
93 requestStream.Write(buffer.ToArray(), 0, length); 93 requestStream.Write(buffer.ToArray(), 0, length);
94 requestStream.Close();
94 95
95 request.BeginGetResponse(delegate(IAsyncResult ar) 96 request.BeginGetResponse(delegate(IAsyncResult ar)
96 { 97 {
97 response = request.EndGetResponse(ar); 98 response = request.EndGetResponse(ar);
98 99 Stream respStream = null;
99 try 100 try
100 { 101 {
101 deserial = (TResponse) deserializer.Deserialize( 102 respStream = response.GetResponseStream();
102 response.GetResponseStream()); 103 deserial = (TResponse)deserializer.Deserialize(
104 respStream);
103 } 105 }
104 catch (System.InvalidOperationException) 106 catch (System.InvalidOperationException)
105 { 107 {
106 } 108 }
109 finally
110 {
111 // Let's not close this
112 //buffer.Close();
113 respStream.Close();
114 response.Close();
115 }
107 116
108 action(deserial); 117 action(deserial);
118
109 }, null); 119 }, null);
110 }, null); 120 }, null);
111 121
122
112 return; 123 return;
113 } 124 }
114 125
@@ -119,14 +130,21 @@ namespace OpenSim.Framework.Servers.HttpServer
119 // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't 130 // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't
120 // documented in MSDN 131 // documented in MSDN
121 response = request.EndGetResponse(res2); 132 response = request.EndGetResponse(res2);
122 133
134 Stream respStream = null;
123 try 135 try
124 { 136 {
125 deserial = (TResponse)deserializer.Deserialize(response.GetResponseStream()); 137 respStream = response.GetResponseStream();
138 deserial = (TResponse)deserializer.Deserialize(respStream);
126 } 139 }
127 catch (System.InvalidOperationException) 140 catch (System.InvalidOperationException)
128 { 141 {
129 } 142 }
143 finally
144 {
145 respStream.Close();
146 response.Close();
147 }
130 } 148 }
131 catch (WebException e) 149 catch (WebException e)
132 { 150 {
@@ -148,7 +166,7 @@ namespace OpenSim.Framework.Servers.HttpServer
148 } 166 }
149 else 167 else
150 { 168 {
151 m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with exception {2}", verb, requestUrl, e); 169 m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with status {2} and message {3}", verb, requestUrl, e.Status, e.Message);
152 } 170 }
153 } 171 }
154 catch (Exception e) 172 catch (Exception e)