diff options
Diffstat (limited to '')
-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 5c34cf4..701fbb0 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) |
@@ -387,8 +387,8 @@ namespace OpenSim.Framework | |||
387 | errorMessage = we.Message; | 387 | errorMessage = we.Message; |
388 | if (we.Status == WebExceptionStatus.ProtocolError) | 388 | if (we.Status == WebExceptionStatus.ProtocolError) |
389 | { | 389 | { |
390 | HttpWebResponse webResponse = (HttpWebResponse)we.Response; | 390 | using (HttpWebResponse webResponse = (HttpWebResponse)we.Response) |
391 | errorMessage = String.Format("[{0}] {1}",webResponse.StatusCode,webResponse.StatusDescription); | 391 | errorMessage = String.Format("[{0}] {1}",webResponse.StatusCode,webResponse.StatusDescription); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | catch (Exception ex) | 394 | catch (Exception ex) |
@@ -834,15 +834,16 @@ namespace OpenSim.Framework | |||
834 | { | 834 | { |
835 | if (e.Response is HttpWebResponse) | 835 | if (e.Response is HttpWebResponse) |
836 | { | 836 | { |
837 | HttpWebResponse httpResponse = (HttpWebResponse)e.Response; | 837 | using (HttpWebResponse httpResponse = (HttpWebResponse)e.Response) |
838 | 838 | { | |
839 | if (httpResponse.StatusCode != HttpStatusCode.NotFound) | 839 | if (httpResponse.StatusCode != HttpStatusCode.NotFound) |
840 | { | 840 | { |
841 | // We don't appear to be handling any other status codes, so log these feailures to that | 841 | // We don't appear to be handling any other status codes, so log these feailures to that |
842 | // people don't spend unnecessary hours hunting phantom bugs. | 842 | // people don't spend unnecessary hours hunting phantom bugs. |
843 | m_log.DebugFormat( | 843 | m_log.DebugFormat( |
844 | "[ASYNC REQUEST]: Request {0} {1} failed with unexpected status code {2}", | 844 | "[ASYNC REQUEST]: Request {0} {1} failed with unexpected status code {2}", |
845 | verb, requestUrl, httpResponse.StatusCode); | 845 | verb, requestUrl, httpResponse.StatusCode); |
846 | } | ||
846 | } | 847 | } |
847 | } | 848 | } |
848 | } | 849 | } |
@@ -983,11 +984,9 @@ namespace OpenSim.Framework | |||
983 | Stream respStream = null; | 984 | Stream respStream = null; |
984 | try | 985 | try |
985 | { | 986 | { |
986 | respStream = resp.GetResponseStream(); | 987 | using (respStream = resp.GetResponseStream()) |
987 | using (StreamReader reader = new StreamReader(respStream)) | 988 | using (StreamReader reader = new StreamReader(respStream)) |
988 | { | 989 | respstring = reader.ReadToEnd(); |
989 | respstring = reader.ReadToEnd(); | ||
990 | } | ||
991 | } | 990 | } |
992 | catch (Exception e) | 991 | catch (Exception e) |
993 | { | 992 | { |
@@ -1127,10 +1126,11 @@ namespace OpenSim.Framework | |||
1127 | { | 1126 | { |
1128 | if (resp.ContentLength != 0) | 1127 | if (resp.ContentLength != 0) |
1129 | { | 1128 | { |
1130 | Stream respStream = resp.GetResponseStream(); | 1129 | using (Stream respStream = resp.GetResponseStream()) |
1131 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); | 1130 | { |
1132 | deserial = (TResponse)deserializer.Deserialize(respStream); | 1131 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); |
1133 | respStream.Close(); | 1132 | deserial = (TResponse)deserializer.Deserialize(respStream); |
1133 | } | ||
1134 | } | 1134 | } |
1135 | else | 1135 | else |
1136 | { | 1136 | { |
@@ -1142,14 +1142,15 @@ namespace OpenSim.Framework | |||
1142 | } | 1142 | } |
1143 | catch (WebException e) | 1143 | catch (WebException e) |
1144 | { | 1144 | { |
1145 | HttpWebResponse hwr = (HttpWebResponse)e.Response; | 1145 | using (HttpWebResponse hwr = (HttpWebResponse)e.Response) |
1146 | 1146 | { | |
1147 | if (hwr != null && hwr.StatusCode == HttpStatusCode.NotFound) | 1147 | if (hwr != null && hwr.StatusCode == HttpStatusCode.NotFound) |
1148 | return deserial; | 1148 | return deserial; |
1149 | else | 1149 | else |
1150 | m_log.ErrorFormat( | 1150 | m_log.ErrorFormat( |
1151 | "[SynchronousRestObjectRequester]: WebException for {0} {1} {2}: {3} {4}", | 1151 | "[SynchronousRestObjectRequester]: WebException for {0} {1} {2}: {3} {4}", |
1152 | verb, requestUrl, typeof(TResponse).ToString(), e.Message, e.StackTrace); | 1152 | verb, requestUrl, typeof(TResponse).ToString(), e.Message, e.StackTrace); |
1153 | } | ||
1153 | } | 1154 | } |
1154 | catch (System.InvalidOperationException) | 1155 | catch (System.InvalidOperationException) |
1155 | { | 1156 | { |