diff options
Diffstat (limited to 'OpenSim/Framework/WebUtil.cs')
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index b85d93d..bf57fd4 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -228,8 +228,8 @@ namespace OpenSim.Framework | |||
228 | errorMessage = we.Message; | 228 | errorMessage = we.Message; |
229 | if (we.Status == WebExceptionStatus.ProtocolError) | 229 | if (we.Status == WebExceptionStatus.ProtocolError) |
230 | { | 230 | { |
231 | HttpWebResponse webResponse = (HttpWebResponse)we.Response; | 231 | using (HttpWebResponse webResponse = (HttpWebResponse)we.Response) |
232 | errorMessage = String.Format("[{0}] {1}",webResponse.StatusCode,webResponse.StatusDescription); | 232 | errorMessage = String.Format("[{0}] {1}", webResponse.StatusCode, webResponse.StatusDescription); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | catch (Exception ex) | 235 | catch (Exception ex) |
@@ -388,8 +388,8 @@ namespace OpenSim.Framework | |||
388 | errorMessage = we.Message; | 388 | errorMessage = we.Message; |
389 | if (we.Status == WebExceptionStatus.ProtocolError) | 389 | if (we.Status == WebExceptionStatus.ProtocolError) |
390 | { | 390 | { |
391 | HttpWebResponse webResponse = (HttpWebResponse)we.Response; | 391 | using (HttpWebResponse webResponse = (HttpWebResponse)we.Response) |
392 | errorMessage = String.Format("[{0}] {1}",webResponse.StatusCode,webResponse.StatusDescription); | 392 | errorMessage = String.Format("[{0}] {1}",webResponse.StatusCode,webResponse.StatusDescription); |
393 | } | 393 | } |
394 | } | 394 | } |
395 | catch (Exception ex) | 395 | catch (Exception ex) |
@@ -837,15 +837,16 @@ namespace OpenSim.Framework | |||
837 | { | 837 | { |
838 | if (e.Response is HttpWebResponse) | 838 | if (e.Response is HttpWebResponse) |
839 | { | 839 | { |
840 | HttpWebResponse httpResponse = (HttpWebResponse)e.Response; | 840 | using (HttpWebResponse httpResponse = (HttpWebResponse)e.Response) |
841 | 841 | { | |
842 | if (httpResponse.StatusCode != HttpStatusCode.NotFound) | 842 | if (httpResponse.StatusCode != HttpStatusCode.NotFound) |
843 | { | 843 | { |
844 | // We don't appear to be handling any other status codes, so log these feailures to that | 844 | // We don't appear to be handling any other status codes, so log these feailures to that |
845 | // people don't spend unnecessary hours hunting phantom bugs. | 845 | // people don't spend unnecessary hours hunting phantom bugs. |
846 | m_log.DebugFormat( | 846 | m_log.DebugFormat( |
847 | "[ASYNC REQUEST]: Request {0} {1} failed with unexpected status code {2}", | 847 | "[ASYNC REQUEST]: Request {0} {1} failed with unexpected status code {2}", |
848 | verb, requestUrl, httpResponse.StatusCode); | 848 | verb, requestUrl, httpResponse.StatusCode); |
849 | } | ||
849 | } | 850 | } |
850 | } | 851 | } |
851 | } | 852 | } |
@@ -995,11 +996,9 @@ namespace OpenSim.Framework | |||
995 | Stream respStream = null; | 996 | Stream respStream = null; |
996 | try | 997 | try |
997 | { | 998 | { |
998 | respStream = resp.GetResponseStream(); | 999 | using (respStream = resp.GetResponseStream()) |
999 | using (StreamReader reader = new StreamReader(respStream)) | 1000 | using (StreamReader reader = new StreamReader(respStream)) |
1000 | { | 1001 | respstring = reader.ReadToEnd(); |
1001 | respstring = reader.ReadToEnd(); | ||
1002 | } | ||
1003 | } | 1002 | } |
1004 | catch (Exception e) | 1003 | catch (Exception e) |
1005 | { | 1004 | { |
@@ -1142,10 +1141,11 @@ namespace OpenSim.Framework | |||
1142 | { | 1141 | { |
1143 | if (resp.ContentLength != 0) | 1142 | if (resp.ContentLength != 0) |
1144 | { | 1143 | { |
1145 | Stream respStream = resp.GetResponseStream(); | 1144 | using (Stream respStream = resp.GetResponseStream()) |
1146 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); | 1145 | { |
1147 | deserial = (TResponse)deserializer.Deserialize(respStream); | 1146 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); |
1148 | respStream.Close(); | 1147 | deserial = (TResponse)deserializer.Deserialize(respStream); |
1148 | } | ||
1149 | } | 1149 | } |
1150 | else | 1150 | else |
1151 | { | 1151 | { |
@@ -1157,14 +1157,15 @@ namespace OpenSim.Framework | |||
1157 | } | 1157 | } |
1158 | catch (WebException e) | 1158 | catch (WebException e) |
1159 | { | 1159 | { |
1160 | HttpWebResponse hwr = (HttpWebResponse)e.Response; | 1160 | using (HttpWebResponse hwr = (HttpWebResponse)e.Response) |
1161 | 1161 | { | |
1162 | if (hwr != null && hwr.StatusCode == HttpStatusCode.NotFound) | 1162 | if (hwr != null && hwr.StatusCode == HttpStatusCode.NotFound) |
1163 | return deserial; | 1163 | return deserial; |
1164 | else | 1164 | else |
1165 | m_log.ErrorFormat( | 1165 | m_log.ErrorFormat( |
1166 | "[SynchronousRestObjectRequester]: WebException for {0} {1} {2}: {3} {4}", | 1166 | "[SynchronousRestObjectRequester]: WebException for {0} {1} {2}: {3} {4}", |
1167 | verb, requestUrl, typeof(TResponse).ToString(), e.Message, e.StackTrace); | 1167 | verb, requestUrl, typeof(TResponse).ToString(), e.Message, e.StackTrace); |
1168 | } | ||
1168 | } | 1169 | } |
1169 | catch (System.InvalidOperationException) | 1170 | catch (System.InvalidOperationException) |
1170 | { | 1171 | { |