diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs index fe69ad3..48e1370 100644 --- a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs +++ b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs | |||
@@ -91,24 +91,31 @@ 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 | respStream.Close(); | ||
112 | response.Close(); | ||
113 | } | ||
107 | 114 | ||
108 | action(deserial); | 115 | action(deserial); |
109 | }, null); | 116 | }, null); |
110 | }, null); | 117 | }, null); |
111 | 118 | ||
112 | return; | 119 | return; |
113 | } | 120 | } |
114 | 121 | ||
@@ -119,14 +126,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 | 126 | // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't |
120 | // documented in MSDN | 127 | // documented in MSDN |
121 | response = request.EndGetResponse(res2); | 128 | response = request.EndGetResponse(res2); |
122 | 129 | ||
130 | Stream respStream = null; | ||
123 | try | 131 | try |
124 | { | 132 | { |
125 | deserial = (TResponse)deserializer.Deserialize(response.GetResponseStream()); | 133 | respStream = response.GetResponseStream(); |
134 | deserial = (TResponse)deserializer.Deserialize(respStream); | ||
126 | } | 135 | } |
127 | catch (System.InvalidOperationException) | 136 | catch (System.InvalidOperationException) |
128 | { | 137 | { |
129 | } | 138 | } |
139 | finally | ||
140 | { | ||
141 | respStream.Close(); | ||
142 | response.Close(); | ||
143 | } | ||
130 | } | 144 | } |
131 | catch (WebException e) | 145 | catch (WebException e) |
132 | { | 146 | { |