diff options
Diffstat (limited to 'OpenSim/Services/Connectors/Hypergrid')
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs | 14 | ||||
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | 69 |
2 files changed, 41 insertions, 42 deletions
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 c542c29..d7e38f1 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | |||
@@ -169,41 +169,45 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
169 | // Let's wait for the response | 169 | // Let's wait for the response |
170 | //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); | 170 | //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); |
171 | 171 | ||
172 | WebResponse webResponse = null; | ||
173 | StreamReader sr = null; | ||
174 | try | 172 | try |
175 | { | 173 | { |
176 | webResponse = AgentCreateRequest.GetResponse(); | 174 | using (WebResponse webResponse = AgentCreateRequest.GetResponse()) |
177 | if (webResponse == null) | ||
178 | { | 175 | { |
179 | m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post"); | 176 | if (webResponse == null) |
180 | } | ||
181 | else | ||
182 | { | ||
183 | |||
184 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
185 | string response = sr.ReadToEnd().Trim(); | ||
186 | m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); | ||
187 | |||
188 | if (!String.IsNullOrEmpty(response)) | ||
189 | { | 177 | { |
190 | try | 178 | m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post"); |
191 | { | 179 | } |
192 | // we assume we got an OSDMap back | 180 | else |
193 | OSDMap r = Util.GetOSDMap(response); | 181 | { |
194 | bool success = r["success"].AsBoolean(); | 182 | using (Stream s = webResponse.GetResponseStream()) |
195 | reason = r["reason"].AsString(); | ||
196 | return success; | ||
197 | } | ||
198 | catch (NullReferenceException e) | ||
199 | { | 183 | { |
200 | m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); | 184 | using (StreamReader sr = new StreamReader(s)) |
201 | 185 | { | |
202 | // check for old style response | 186 | string response = sr.ReadToEnd().Trim(); |
203 | if (response.ToLower().StartsWith("true")) | 187 | m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); |
204 | return true; | 188 | |
205 | 189 | if (!String.IsNullOrEmpty(response)) | |
206 | return false; | 190 | { |
191 | try | ||
192 | { | ||
193 | // we assume we got an OSDMap back | ||
194 | OSDMap r = Util.GetOSDMap(response); | ||
195 | bool success = r["success"].AsBoolean(); | ||
196 | reason = r["reason"].AsString(); | ||
197 | return success; | ||
198 | } | ||
199 | catch (NullReferenceException e) | ||
200 | { | ||
201 | m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); | ||
202 | |||
203 | // check for old style response | ||
204 | if (response.ToLower().StartsWith("true")) | ||
205 | return true; | ||
206 | |||
207 | return false; | ||
208 | } | ||
209 | } | ||
210 | } | ||
207 | } | 211 | } |
208 | } | 212 | } |
209 | } | 213 | } |
@@ -214,11 +218,6 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
214 | reason = "Destination did not reply"; | 218 | reason = "Destination did not reply"; |
215 | return false; | 219 | return false; |
216 | } | 220 | } |
217 | finally | ||
218 | { | ||
219 | if (sr != null) | ||
220 | sr.Close(); | ||
221 | } | ||
222 | 221 | ||
223 | return true; | 222 | return true; |
224 | 223 | ||