diff options
Diffstat (limited to 'OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs')
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs index 5004d99..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,21 +72,28 @@ 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 | public virtual string Helo() | 83 | public virtual string Helo() |
77 | { | 84 | { |
78 | HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI); | 85 | if (String.IsNullOrEmpty(m_ServerURI)) |
79 | // Eventually we need to switch to HEAD | 86 | { |
80 | /* req.Method = "HEAD"; */ | 87 | m_log.WarnFormat("[HELO SERVICE]: Unable to invoke HELO due to empty URL"); |
88 | return String.Empty; | ||
89 | } | ||
81 | 90 | ||
82 | try | 91 | try |
83 | { | 92 | { |
93 | HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI); | ||
94 | // Eventually we need to switch to HEAD | ||
95 | /* req.Method = "HEAD"; */ | ||
96 | |||
84 | using (WebResponse response = req.GetResponse()) | 97 | using (WebResponse response = req.GetResponse()) |
85 | { | 98 | { |
86 | if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null | 99 | if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null |