diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs index 5c50936..b5e6d69 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs | |||
@@ -47,16 +47,22 @@ namespace OpenSim.Services.Connectors | |||
47 | 47 | ||
48 | public HeloServicesConnector(string serverURI) | 48 | public HeloServicesConnector(string serverURI) |
49 | { | 49 | { |
50 | if (!serverURI.EndsWith("=")) | 50 | try |
51 | m_ServerURI = serverURI.TrimEnd('/') + "/helo/"; | ||
52 | else | ||
53 | { | 51 | { |
54 | // Simian sends malformed urls like this: | 52 | Uri uri; |
55 | // http://valley.virtualportland.org/simtest/Grid/?id= | 53 | |
56 | // | 54 | if (!serverURI.EndsWith("=")) |
57 | try | 55 | { |
56 | // Let's check if this is a valid URI, because it may not be | ||
57 | uri = new Uri(serverURI); | ||
58 | m_ServerURI = serverURI.TrimEnd('/') + "/helo/"; | ||
59 | } | ||
60 | else | ||
58 | { | 61 | { |
59 | Uri uri = new Uri(serverURI + "xxx"); | 62 | // Simian sends malformed urls like this: |
63 | // http://valley.virtualportland.org/simtest/Grid/?id= | ||
64 | // | ||
65 | uri = new Uri(serverURI + "xxx"); | ||
60 | if (uri.Query == string.Empty) | 66 | if (uri.Query == string.Empty) |
61 | m_ServerURI = serverURI.TrimEnd('/') + "/helo/"; | 67 | m_ServerURI = serverURI.TrimEnd('/') + "/helo/"; |
62 | else | 68 | else |
@@ -66,26 +72,34 @@ namespace OpenSim.Services.Connectors | |||
66 | m_ServerURI = m_ServerURI.TrimEnd('/') + "/helo/"; | 72 | m_ServerURI = m_ServerURI.TrimEnd('/') + "/helo/"; |
67 | } | 73 | } |
68 | } | 74 | } |
69 | catch (UriFormatException) | 75 | |
70 | { | 76 | } |
71 | m_log.WarnFormat("[HELO SERVICE]: Malformed URL {0}", serverURI); | 77 | catch (UriFormatException) |
72 | } | 78 | { |
79 | m_log.WarnFormat("[HELO SERVICE]: Malformed URL {0}", serverURI); | ||
73 | } | 80 | } |
74 | } | 81 | } |
75 | 82 | ||
76 | |||
77 | public virtual string Helo() | 83 | public virtual string Helo() |
78 | { | 84 | { |
79 | HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI); | 85 | if (String.IsNullOrEmpty(m_ServerURI)) |
80 | // Eventually we need to switch to HEAD | 86 | { |
81 | /* req.Method = "HEAD"; */ | 87 | m_log.WarnFormat("[HELO SERVICE]: Unable to invoke HELO due to empty URL"); |
88 | return String.Empty; | ||
89 | } | ||
82 | 90 | ||
83 | try | 91 | try |
84 | { | 92 | { |
85 | WebResponse response = req.GetResponse(); | 93 | HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI); |
86 | if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null | 94 | // Eventually we need to switch to HEAD |
87 | return string.Empty; | 95 | /* req.Method = "HEAD"; */ |
88 | return response.Headers.Get("X-Handlers-Provided"); | 96 | |
97 | using (WebResponse response = req.GetResponse()) | ||
98 | { | ||
99 | if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null | ||
100 | return string.Empty; | ||
101 | return response.Headers.Get("X-Handlers-Provided"); | ||
102 | } | ||
89 | } | 103 | } |
90 | catch (Exception e) | 104 | catch (Exception e) |
91 | { | 105 | { |
@@ -95,6 +109,5 @@ namespace OpenSim.Services.Connectors | |||
95 | // fail | 109 | // fail |
96 | return string.Empty; | 110 | return string.Empty; |
97 | } | 111 | } |
98 | |||
99 | } | 112 | } |
100 | } | 113 | } \ No newline at end of file |