diff options
author | Melanie | 2013-02-27 18:05:04 +0000 |
---|---|---|
committer | Melanie | 2013-02-27 18:05:04 +0000 |
commit | 578174d21c82e7249016e31f0c63215e67f92f17 (patch) | |
tree | c9c970d2ce4836dcf894922172d784d16cbc2837 /OpenSim/Framework | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Improve description of GenerateMapTiles config option (diff) | |
download | opensim-SC-578174d21c82e7249016e31f0c63215e67f92f17.zip opensim-SC-578174d21c82e7249016e31f0c63215e67f92f17.tar.gz opensim-SC-578174d21c82e7249016e31f0c63215e67f92f17.tar.bz2 opensim-SC-578174d21c82e7249016e31f0c63215e67f92f17.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs | 32 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/RestSessionService.cs | 15 | ||||
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 61 |
3 files changed, 52 insertions, 56 deletions
diff --git a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs index 3dce578..6681c37 100644 --- a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs +++ b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs | |||
@@ -65,23 +65,27 @@ namespace OpenSim.Framework.Configuration.HTTP | |||
65 | byte[] buf = new byte[8192]; | 65 | byte[] buf = new byte[8192]; |
66 | HttpWebRequest request = | 66 | HttpWebRequest request = |
67 | (HttpWebRequest) WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName); | 67 | (HttpWebRequest) WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName); |
68 | HttpWebResponse response = (HttpWebResponse) request.GetResponse(); | 68 | using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) |
69 | |||
70 | Stream resStream = response.GetResponseStream(); | ||
71 | |||
72 | string tempString = null; | ||
73 | int count = 0; | ||
74 | |||
75 | do | ||
76 | { | 69 | { |
77 | count = resStream.Read(buf, 0, buf.Length); | 70 | using (Stream resStream = response.GetResponseStream()) |
78 | if (count != 0) | ||
79 | { | 71 | { |
80 | tempString = Util.UTF8.GetString(buf, 0, count); | 72 | string tempString = null; |
81 | sb.Append(tempString); | 73 | int count = 0; |
74 | |||
75 | do | ||
76 | { | ||
77 | count = resStream.Read(buf, 0, buf.Length); | ||
78 | if (count != 0) | ||
79 | { | ||
80 | tempString = Util.UTF8.GetString(buf, 0, count); | ||
81 | sb.Append(tempString); | ||
82 | } | ||
83 | } | ||
84 | while (count > 0); | ||
85 | |||
86 | LoadDataFromString(sb.ToString()); | ||
82 | } | 87 | } |
83 | } while (count > 0); | 88 | } |
84 | LoadDataFromString(sb.ToString()); | ||
85 | } | 89 | } |
86 | catch (WebException) | 90 | catch (WebException) |
87 | { | 91 | { |
diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs index 19c03a8..edcd134 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs | |||
@@ -101,20 +101,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
101 | using (WebResponse resp = request.GetResponse()) | 101 | using (WebResponse resp = request.GetResponse()) |
102 | { | 102 | { |
103 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); | 103 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); |
104 | Stream respStream = null; | 104 | |
105 | try | 105 | using (Stream respStream = resp.GetResponseStream()) |
106 | { | ||
107 | respStream = resp.GetResponseStream(); | ||
108 | deserial = (TResponse)deserializer.Deserialize(respStream); | 106 | deserial = (TResponse)deserializer.Deserialize(respStream); |
109 | } | ||
110 | catch { } | ||
111 | finally | ||
112 | { | ||
113 | if (respStream != null) | ||
114 | respStream.Close(); | ||
115 | resp.Close(); | ||
116 | } | ||
117 | } | 107 | } |
108 | |||
118 | return deserial; | 109 | return deserial; |
119 | } | 110 | } |
120 | } | 111 | } |
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 | { |