aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ConsoleClient/Requester.cs19
-rw-r--r--OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs32
-rw-r--r--OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs41
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestSessionService.cs15
-rw-r--r--OpenSim/Framework/WebUtil.cs61
-rw-r--r--OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs16
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs30
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs21
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs12
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs46
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs14
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs69
-rw-r--r--OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs34
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs47
14 files changed, 245 insertions, 212 deletions
diff --git a/OpenSim/ConsoleClient/Requester.cs b/OpenSim/ConsoleClient/Requester.cs
index aabb02c..0a21328 100644
--- a/OpenSim/ConsoleClient/Requester.cs
+++ b/OpenSim/ConsoleClient/Requester.cs
@@ -44,7 +44,6 @@ namespace OpenSim.ConsoleClient
44 ReplyDelegate action) 44 ReplyDelegate action)
45 { 45 {
46 WebRequest request = WebRequest.Create(requestUrl); 46 WebRequest request = WebRequest.Create(requestUrl);
47 WebResponse response = null;
48 47
49 request.Method = "POST"; 48 request.Method = "POST";
50 49
@@ -64,16 +63,18 @@ namespace OpenSim.ConsoleClient
64 { 63 {
65 string reply = String.Empty; 64 string reply = String.Empty;
66 65
67 response = request.EndGetResponse(ar); 66 using (WebResponse response = request.EndGetResponse(ar))
68
69 try
70 { 67 {
71 StreamReader r = new StreamReader(response.GetResponseStream()); 68 try
72 reply = r.ReadToEnd(); 69 {
70 using (Stream s = response.GetResponseStream())
71 using (StreamReader r = new StreamReader(s))
72 reply = r.ReadToEnd();
73 73
74 } 74 }
75 catch (System.InvalidOperationException) 75 catch (System.InvalidOperationException)
76 { 76 {
77 }
77 } 78 }
78 79
79 action(requestUrl, data, reply); 80 action(requestUrl, data, reply);
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/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
index a2f5d9c..05c64fa 100644
--- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
+++ b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
@@ -74,16 +74,26 @@ namespace OpenSim.Framework.RegionLoader.Web
74 74
75 try 75 try
76 { 76 {
77 HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse();
78 m_log.Debug("[WEBLOADER]: Downloading region information...");
79 StreamReader reader = new StreamReader(webResponse.GetResponseStream());
80 string xmlSource = String.Empty; 77 string xmlSource = String.Empty;
81 string tempStr = reader.ReadLine(); 78
82 while (tempStr != null) 79 using (HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse())
83 { 80 {
84 xmlSource = xmlSource + tempStr; 81 m_log.Debug("[WEBLOADER]: Downloading region information...");
85 tempStr = reader.ReadLine(); 82
83 using (Stream s = webResponse.GetResponseStream())
84 {
85 using (StreamReader reader = new StreamReader(s))
86 {
87 string tempStr = reader.ReadLine();
88 while (tempStr != null)
89 {
90 xmlSource = xmlSource + tempStr;
91 tempStr = reader.ReadLine();
92 }
93 }
94 }
86 } 95 }
96
87 m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + 97 m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " +
88 xmlSource.Length); 98 xmlSource.Length);
89 XmlDocument xmlDoc = new XmlDocument(); 99 XmlDocument xmlDoc = new XmlDocument();
@@ -107,17 +117,24 @@ namespace OpenSim.Framework.RegionLoader.Web
107 } 117 }
108 catch (WebException ex) 118 catch (WebException ex)
109 { 119 {
110 if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound) 120 using (HttpWebResponse response = (HttpWebResponse)ex.Response)
111 { 121 {
112 if (!allowRegionless) 122 if (response.StatusCode == HttpStatusCode.NotFound)
123 {
124 if (!allowRegionless)
125 throw ex;
126 }
127 else
128 {
113 throw ex; 129 throw ex;
130 }
114 } 131 }
115 else
116 throw ex;
117 } 132 }
118 133
119 if (regionCount > 0 | allowRegionless) 134 if (regionCount > 0 | allowRegionless)
135 {
120 return regionInfos; 136 return regionInfos;
137 }
121 else 138 else
122 { 139 {
123 m_log.Error("[WEBLOADER]: No region configs were available."); 140 m_log.Error("[WEBLOADER]: No region configs were available.");
@@ -127,4 +144,4 @@ namespace OpenSim.Framework.RegionLoader.Web
127 } 144 }
128 } 145 }
129 } 146 }
130} 147} \ No newline at end of file
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 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 {
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index 689e8a7..f04fabe 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -838,13 +838,17 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
838 try 838 try
839 { 839 {
840 WebRequest request = HttpWebRequest.Create(url); 840 WebRequest request = HttpWebRequest.Create(url);
841//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. 841
842//Ckrinke Stream str = null; 842 using (HttpWebResponse response = (HttpWebResponse)(request).GetResponse())
843 HttpWebResponse response = (HttpWebResponse)(request).GetResponse();
844 if (response.StatusCode == HttpStatusCode.OK)
845 { 843 {
846 Bitmap image = new Bitmap(response.GetResponseStream()); 844 if (response.StatusCode == HttpStatusCode.OK)
847 return image; 845 {
846 using (Stream s = response.GetResponseStream())
847 {
848 Bitmap image = new Bitmap(s);
849 return image;
850 }
851 }
848 } 852 }
849 } 853 }
850 catch { } 854 catch { }
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 912d50a..c50ab64 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -868,20 +868,22 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
868 } 868 }
869 869
870 string response_mapItems_reply = null; 870 string response_mapItems_reply = null;
871 { // get the response 871 {
872 StreamReader sr = null;
873 try 872 try
874 { 873 {
875 WebResponse webResponse = mapitemsrequest.GetResponse(); 874 using (WebResponse webResponse = mapitemsrequest.GetResponse())
876 if (webResponse != null)
877 {
878 sr = new StreamReader(webResponse.GetResponseStream());
879 response_mapItems_reply = sr.ReadToEnd().Trim();
880 }
881 else
882 { 875 {
883 return new OSDMap(); 876 if (webResponse != null)
884 } 877 {
878 using (Stream s = webResponse.GetResponseStream())
879 using (StreamReader sr = new StreamReader(s))
880 response_mapItems_reply = sr.ReadToEnd().Trim();
881 }
882 else
883 {
884 return new OSDMap();
885 }
886 }
885 } 887 }
886 catch (WebException) 888 catch (WebException)
887 { 889 {
@@ -908,11 +910,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
908 910
909 return responseMap; 911 return responseMap;
910 } 912 }
911 finally
912 {
913 if (sr != null)
914 sr.Close();
915 }
916 913
917 OSD rezResponse = null; 914 OSD rezResponse = null;
918 try 915 try
@@ -926,6 +923,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
926 { 923 {
927 m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message); 924 m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message);
928 responseMap["connect"] = OSD.FromBoolean(false); 925 responseMap["connect"] = OSD.FromBoolean(false);
926
929 lock (m_blacklistedregions) 927 lock (m_blacklistedregions)
930 { 928 {
931 if (!m_blacklistedregions.ContainsKey(regionhandle)) 929 if (!m_blacklistedregions.ContainsKey(regionhandle))
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
index 37ab35a..ef1b92e 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
@@ -551,13 +551,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
551 reqStream.Close(); 551 reqStream.Close();
552 } 552 }
553 553
554 HttpWebResponse fwdrsp = (HttpWebResponse)forwardreq.GetResponse(); 554 using (HttpWebResponse fwdrsp = (HttpWebResponse)forwardreq.GetResponse())
555 Encoding encoding = Util.UTF8; 555 {
556 StreamReader fwdresponsestream = new StreamReader(fwdrsp.GetResponseStream(), encoding); 556 Encoding encoding = Util.UTF8;
557 fwdresponsestr = fwdresponsestream.ReadToEnd(); 557
558 fwdresponsecontenttype = fwdrsp.ContentType; 558 using (Stream s = fwdrsp.GetResponseStream())
559 fwdresponsecode = (int)fwdrsp.StatusCode; 559 {
560 fwdresponsestream.Close(); 560 using (StreamReader fwdresponsestream = new StreamReader(s))
561 {
562 fwdresponsestr = fwdresponsestream.ReadToEnd();
563 fwdresponsecontenttype = fwdrsp.ContentType;
564 fwdresponsecode = (int)fwdrsp.StatusCode;
565 }
566 }
567 }
561 568
562 response["content_type"] = fwdresponsecontenttype; 569 response["content_type"] = fwdresponsecontenttype;
563 response["str_response_string"] = fwdresponsestr; 570 response["str_response_string"] = fwdresponsestr;
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
index 881807a..cb69411 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
@@ -1116,18 +1116,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1116 // Otherwise prepare the request 1116 // Otherwise prepare the request
1117 m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); 1117 m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl);
1118 1118
1119 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); 1119 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl);
1120 HttpWebResponse rsp = null;
1121 1120
1122 // We are sending just parameters, no content 1121 // We are sending just parameters, no content
1123 req.ContentLength = 0; 1122 req.ContentLength = 0;
1124 1123
1125 // Send request and retrieve the response 1124 // Send request and retrieve the response
1126 rsp = (HttpWebResponse)req.GetResponse(); 1125 using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse())
1127 1126 using (Stream s = rsp.GetResponseStream())
1128 XmlTextReader rdr = new XmlTextReader(rsp.GetResponseStream()); 1127 using (XmlTextReader rdr = new XmlTextReader(s))
1129 doc.Load(rdr); 1128 doc.Load(rdr);
1130 rdr.Close();
1131 } 1129 }
1132 catch (Exception e) 1130 catch (Exception e)
1133 { 1131 {
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index 1101851..71b24ac 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -1146,28 +1146,38 @@ namespace Nwc.XmlRpc
1146 request.AllowWriteStreamBuffering = true; 1146 request.AllowWriteStreamBuffering = true;
1147 request.KeepAlive = !_disableKeepAlive; 1147 request.KeepAlive = !_disableKeepAlive;
1148 1148
1149 Stream stream = request.GetRequestStream(); 1149 using (Stream stream = request.GetRequestStream())
1150 XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII);
1151 _serializer.Serialize(xml, this);
1152 xml.Flush();
1153 xml.Close();
1154
1155 HttpWebResponse response = (HttpWebResponse)request.GetResponse();
1156 StreamReader input = new StreamReader(response.GetResponseStream());
1157
1158 string inputXml = input.ReadToEnd();
1159 XmlRpcResponse resp;
1160 try
1161 { 1150 {
1162 resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml); 1151 using (XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII))
1152 {
1153 _serializer.Serialize(xml, this);
1154 xml.Flush();
1155 }
1163 } 1156 }
1164 catch (Exception e) 1157
1158 XmlRpcResponse resp;
1159
1160 using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
1165 { 1161 {
1166 RequestResponse = inputXml; 1162 using (Stream s = response.GetResponseStream())
1167 throw e; 1163 {
1164 using (StreamReader input = new StreamReader(s))
1165 {
1166 string inputXml = input.ReadToEnd();
1167
1168 try
1169 {
1170 resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml);
1171 }
1172 catch (Exception e)
1173 {
1174 RequestResponse = inputXml;
1175 throw e;
1176 }
1177 }
1178 }
1168 } 1179 }
1169 input.Close(); 1180
1170 response.Close();
1171 return resp; 1181 return resp;
1172 } 1182 }
1173 } 1183 }
diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
index 5c50936..5004d99 100644
--- a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
@@ -73,7 +73,6 @@ namespace OpenSim.Services.Connectors
73 } 73 }
74 } 74 }
75 75
76
77 public virtual string Helo() 76 public virtual string Helo()
78 { 77 {
79 HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI); 78 HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI);
@@ -82,10 +81,12 @@ namespace OpenSim.Services.Connectors
82 81
83 try 82 try
84 { 83 {
85 WebResponse response = req.GetResponse(); 84 using (WebResponse response = req.GetResponse())
86 if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null 85 {
87 return string.Empty; 86 if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null
88 return response.Headers.Get("X-Handlers-Provided"); 87 return string.Empty;
88 return response.Headers.Get("X-Handlers-Provided");
89 }
89 } 90 }
90 catch (Exception e) 91 catch (Exception e)
91 { 92 {
@@ -95,6 +96,5 @@ namespace OpenSim.Services.Connectors
95 // fail 96 // fail
96 return string.Empty; 97 return string.Empty;
97 } 98 }
98
99 } 99 }
100} 100} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 2f263ae..47d0cce 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -171,41 +171,45 @@ namespace OpenSim.Services.Connectors.Hypergrid
171 // Let's wait for the response 171 // Let's wait for the response
172 //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); 172 //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
173 173
174 WebResponse webResponse = null;
175 StreamReader sr = null;
176 try 174 try
177 { 175 {
178 webResponse = AgentCreateRequest.GetResponse(); 176 using (WebResponse webResponse = AgentCreateRequest.GetResponse())
179 if (webResponse == null)
180 { 177 {
181 m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post"); 178 if (webResponse == null)
182 }
183 else
184 {
185
186 sr = new StreamReader(webResponse.GetResponseStream());
187 string response = sr.ReadToEnd().Trim();
188 m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
189
190 if (!String.IsNullOrEmpty(response))
191 { 179 {
192 try 180 m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post");
193 { 181 }
194 // we assume we got an OSDMap back 182 else
195 OSDMap r = Util.GetOSDMap(response); 183 {
196 bool success = r["success"].AsBoolean(); 184 using (Stream s = webResponse.GetResponseStream())
197 reason = r["reason"].AsString();
198 return success;
199 }
200 catch (NullReferenceException e)
201 { 185 {
202 m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); 186 using (StreamReader sr = new StreamReader(s))
203 187 {
204 // check for old style response 188 string response = sr.ReadToEnd().Trim();
205 if (response.ToLower().StartsWith("true")) 189 m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
206 return true; 190
207 191 if (!String.IsNullOrEmpty(response))
208 return false; 192 {
193 try
194 {
195 // we assume we got an OSDMap back
196 OSDMap r = Util.GetOSDMap(response);
197 bool success = r["success"].AsBoolean();
198 reason = r["reason"].AsString();
199 return success;
200 }
201 catch (NullReferenceException e)
202 {
203 m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
204
205 // check for old style response
206 if (response.ToLower().StartsWith("true"))
207 return true;
208
209 return false;
210 }
211 }
212 }
209 } 213 }
210 } 214 }
211 } 215 }
@@ -216,11 +220,6 @@ namespace OpenSim.Services.Connectors.Hypergrid
216 reason = "Destination did not reply"; 220 reason = "Destination did not reply";
217 return false; 221 return false;
218 } 222 }
219 finally
220 {
221 if (sr != null)
222 sr.Close();
223 }
224 223
225 return true; 224 return true;
226 225
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
index 7429293..5948380 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
@@ -168,22 +168,27 @@ namespace OpenSim.Services.Connectors
168 // Let's wait for the response 168 // Let's wait for the response
169 //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); 169 //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall");
170 170
171 StreamReader sr = null;
172 try 171 try
173 { 172 {
174 WebResponse webResponse = helloNeighbourRequest.GetResponse(); 173 using (WebResponse webResponse = helloNeighbourRequest.GetResponse())
175 if (webResponse == null)
176 { 174 {
177 m_log.DebugFormat( 175 if (webResponse == null)
178 "[REST COMMS]: Null reply on DoHelloNeighbourCall post from {0} to {1}", 176 {
179 thisRegion.RegionName, region.RegionName); 177 m_log.DebugFormat(
178 "[REST COMMS]: Null reply on DoHelloNeighbourCall post from {0} to {1}",
179 thisRegion.RegionName, region.RegionName);
180 }
181
182 using (Stream s = webResponse.GetResponseStream())
183 {
184 using (StreamReader sr = new StreamReader(s))
185 {
186 //reply = sr.ReadToEnd().Trim();
187 sr.ReadToEnd().Trim();
188 //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
189 }
190 }
180 } 191 }
181
182 sr = new StreamReader(webResponse.GetResponseStream());
183 //reply = sr.ReadToEnd().Trim();
184 sr.ReadToEnd().Trim();
185 //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
186
187 } 192 }
188 catch (Exception e) 193 catch (Exception e)
189 { 194 {
@@ -193,11 +198,6 @@ namespace OpenSim.Services.Connectors
193 198
194 return false; 199 return false;
195 } 200 }
196 finally
197 {
198 if (sr != null)
199 sr.Close();
200 }
201 201
202 return true; 202 return true;
203 } 203 }
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
index 63a32e7..74b980c 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
@@ -339,36 +339,38 @@ namespace OpenSim.Services.Connectors.SimianGrid
339 // Simian does not require the asset ID to be in the URL because it's in the post data. 339 // Simian does not require the asset ID to be in the URL because it's in the post data.
340 // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs 340 // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs
341 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString()); 341 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString());
342
343 HttpWebResponse response = MultipartForm.Post(request, postParameters);
344 using (Stream responseStream = response.GetResponseStream())
345 {
346 string responseStr = null;
347 342
348 try 343 using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
344 {
345 using (Stream responseStream = response.GetResponseStream())
349 { 346 {
350 responseStr = responseStream.GetStreamString(); 347 string responseStr = null;
351 OSD responseOSD = OSDParser.Deserialize(responseStr); 348
352 if (responseOSD.Type == OSDType.Map) 349 try
353 { 350 {
354 OSDMap responseMap = (OSDMap)responseOSD; 351 responseStr = responseStream.GetStreamString();
355 if (responseMap["Success"].AsBoolean()) 352 OSD responseOSD = OSDParser.Deserialize(responseStr);
356 return asset.ID; 353 if (responseOSD.Type == OSDType.Map)
354 {
355 OSDMap responseMap = (OSDMap)responseOSD;
356 if (responseMap["Success"].AsBoolean())
357 return asset.ID;
358 else
359 errorMessage = "Upload failed: " + responseMap["Message"].AsString();
360 }
357 else 361 else
358 errorMessage = "Upload failed: " + responseMap["Message"].AsString(); 362 {
363 errorMessage = "Response format was invalid:\n" + responseStr;
364 }
359 } 365 }
360 else 366 catch (Exception ex)
361 { 367 {
362 errorMessage = "Response format was invalid:\n" + responseStr; 368 if (!String.IsNullOrEmpty(responseStr))
369 errorMessage = "Failed to parse the response:\n" + responseStr;
370 else
371 errorMessage = "Failed to retrieve the response: " + ex.Message;
363 } 372 }
364 } 373 }
365 catch (Exception ex)
366 {
367 if (!String.IsNullOrEmpty(responseStr))
368 errorMessage = "Failed to parse the response:\n" + responseStr;
369 else
370 errorMessage = "Failed to retrieve the response: " + ex.Message;
371 }
372 } 374 }
373 } 375 }
374 catch (WebException ex) 376 catch (WebException ex)
@@ -378,6 +380,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
378 380
379 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}", 381 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}",
380 asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage); 382 asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage);
383
381 return null; 384 return null;
382 } 385 }
383 386