diff options
Diffstat (limited to 'OpenSim/Framework/Servers/OSHttpRequestPump.cs')
-rw-r--r-- | OpenSim/Framework/Servers/OSHttpRequestPump.cs | 58 |
1 files changed, 19 insertions, 39 deletions
diff --git a/OpenSim/Framework/Servers/OSHttpRequestPump.cs b/OpenSim/Framework/Servers/OSHttpRequestPump.cs index be4c3ff..d05e706 100644 --- a/OpenSim/Framework/Servers/OSHttpRequestPump.cs +++ b/OpenSim/Framework/Servers/OSHttpRequestPump.cs | |||
@@ -175,6 +175,7 @@ namespace OpenSim.Framework.Servers | |||
175 | _log.DebugFormat("[{0}] MatchHandlers for {1}", EngineID, req); | 175 | _log.DebugFormat("[{0}] MatchHandlers for {1}", EngineID, req); |
176 | foreach (OSHttpHandler h in handlers) | 176 | foreach (OSHttpHandler h in handlers) |
177 | { | 177 | { |
178 | Regex methodRegex = h.Method; | ||
178 | Regex pathRegex = h.Path; | 179 | Regex pathRegex = h.Path; |
179 | Dictionary<string, Regex> headerRegexs = h.Headers; | 180 | Dictionary<string, Regex> headerRegexs = h.Headers; |
180 | Regex endPointsRegex = h.IPEndPointWhitelist; | 181 | Regex endPointsRegex = h.IPEndPointWhitelist; |
@@ -198,10 +199,18 @@ namespace OpenSim.Framework.Servers | |||
198 | } | 199 | } |
199 | } | 200 | } |
200 | 201 | ||
202 | if (null != methodRegex) | ||
203 | { | ||
204 | Match m = methodRegex.Match(req.HttpMethod); | ||
205 | if (!m.Success) continue; | ||
206 | |||
207 | scoredHandlers[h]++; | ||
208 | } | ||
209 | |||
201 | // whitelist ok, now check path | 210 | // whitelist ok, now check path |
202 | if (null != pathRegex) | 211 | if (null != pathRegex) |
203 | { | 212 | { |
204 | Match m = pathRegex.Match(req.HttpRequest.Uri.AbsolutePath); | 213 | Match m = pathRegex.Match(req.RawUrl); |
205 | if (!m.Success) continue; | 214 | if (!m.Success) continue; |
206 | 215 | ||
207 | scoredHandlers[h] = m.ToString().Length; | 216 | scoredHandlers[h] = m.ToString().Length; |
@@ -227,8 +236,7 @@ namespace OpenSim.Framework.Servers | |||
227 | { | 236 | { |
228 | // no: remove the handler if it was added | 237 | // no: remove the handler if it was added |
229 | // earlier and on to the next one | 238 | // earlier and on to the next one |
230 | _LogDumpOSHttpHandler(String.Format("[{0}] dropping handler for {1}: null {2} header field", | 239 | _log.DebugFormat("[{0}] dropping handler for {1}: null {2} header field: {3}", EngineID, req, tag, h); |
231 | EngineID, req, tag), h); | ||
232 | 240 | ||
233 | scoredHandlers.Remove(h); | 241 | scoredHandlers.Remove(h); |
234 | break; | 242 | break; |
@@ -240,8 +248,8 @@ namespace OpenSim.Framework.Servers | |||
240 | if (!hm.Success) { | 248 | if (!hm.Success) { |
241 | // no: remove the handler if it was added | 249 | // no: remove the handler if it was added |
242 | // earlier and on to the next one | 250 | // earlier and on to the next one |
243 | _LogDumpOSHttpHandler(String.Format("[{0}] dropping handler for {1}: {2} header field content \"{3}\" does not match regex {4}", | 251 | _log.DebugFormat("[{0}] dropping handler for {1}: {2} header field content \"{3}\" does not match regex {4}: {5}", |
244 | EngineID, req, tag, headers[tag], headerRegexs[tag].ToString()), h); | 252 | EngineID, req, tag, headers[tag], headerRegexs[tag].ToString(), h); |
245 | scoredHandlers.Remove(h); | 253 | scoredHandlers.Remove(h); |
246 | break; | 254 | break; |
247 | } | 255 | } |
@@ -252,14 +260,13 @@ namespace OpenSim.Framework.Servers | |||
252 | if ((null != h.ContentTypeChecker) && !h.ContentTypeChecker(req)) | 260 | if ((null != h.ContentTypeChecker) && !h.ContentTypeChecker(req)) |
253 | { | 261 | { |
254 | scoredHandlers.Remove(h); | 262 | scoredHandlers.Remove(h); |
255 | _LogDumpOSHttpHandler(String.Format("[{0}] dropping handler for {1}: content checker returned false", | 263 | _log.DebugFormat("[{0}] dropping handler for {1}: content checker returned false: {2}", EngineID, req, h); |
256 | EngineID, req), h); | ||
257 | break; | 264 | break; |
258 | } | 265 | } |
259 | 266 | ||
260 | // ok: header matches | 267 | // ok: header matches |
261 | headersMatch++; | 268 | headersMatch++; |
262 | _LogDumpOSHttpHandler(String.Format("[{0}] MatchHandlers: found handler for {1}", EngineID, req), h); | 269 | _log.DebugFormat("[{0}] MatchHandlers: found handler for {1}: {2}", EngineID, req, h.ToString()); |
263 | continue; | 270 | continue; |
264 | } | 271 | } |
265 | // check whether h got kicked out | 272 | // check whether h got kicked out |
@@ -269,48 +276,21 @@ namespace OpenSim.Framework.Servers | |||
269 | } | 276 | } |
270 | } | 277 | } |
271 | 278 | ||
272 | foreach (OSHttpHandler hh in scoredHandlers.Keys) | ||
273 | { | ||
274 | _LogDumpOSHttpHandler("scoredHandlers:", hh); | ||
275 | } | ||
276 | |||
277 | List<OSHttpHandler> matchingHandlers = new List<OSHttpHandler>(scoredHandlers.Keys); | 279 | List<OSHttpHandler> matchingHandlers = new List<OSHttpHandler>(scoredHandlers.Keys); |
278 | _LogDumpOSHttpHandlerList("before sort: ", matchingHandlers); | ||
279 | matchingHandlers.Sort(delegate(OSHttpHandler x, OSHttpHandler y) | 280 | matchingHandlers.Sort(delegate(OSHttpHandler x, OSHttpHandler y) |
280 | { | 281 | { |
281 | return scoredHandlers[x] - scoredHandlers[y]; | 282 | return scoredHandlers[x] - scoredHandlers[y]; |
282 | }); | 283 | }); |
283 | 284 | LogDumpHandlerList(matchingHandlers); | |
284 | _LogDumpOSHttpHandlerList("after sort: ", matchingHandlers); | ||
285 | |||
286 | return matchingHandlers; | 285 | return matchingHandlers; |
287 | } | 286 | } |
288 | 287 | ||
289 | [ConditionalAttribute("DEBUGGING")] | 288 | [ConditionalAttribute("DEBUGGING")] |
290 | private void _LogDumpOSHttpHandler(string msg, OSHttpHandler h) | 289 | private void LogDumpHandlerList(List<OSHttpHandler> l) |
291 | { | ||
292 | _log.Debug(msg); | ||
293 | |||
294 | StringWriter sw = new StringWriter(); | ||
295 | sw.WriteLine("{0}", h.ToString()); | ||
296 | sw.WriteLine(" path regex {0}", null == h.Path ? "null": h.Path.ToString()); | ||
297 | foreach (string tag in h.Headers.Keys) | ||
298 | { | ||
299 | sw.WriteLine(" header[{0}] {1}", tag, h.Headers[tag].ToString()); | ||
300 | } | ||
301 | sw.WriteLine(" IP whitelist {0}", null == h.IPEndPointWhitelist ? "null" : h.IPEndPointWhitelist.ToString()); | ||
302 | sw.WriteLine(); | ||
303 | sw.Close(); | ||
304 | |||
305 | _log.Debug(sw.ToString()); | ||
306 | } | ||
307 | |||
308 | [ConditionalAttribute("DEBUGGING")] | ||
309 | private void _LogDumpOSHttpHandlerList(string msg, List<OSHttpHandler> l) | ||
310 | { | 290 | { |
311 | _log.DebugFormat("OSHttpHandlerList dump: {0}", msg); | 291 | _log.DebugFormat("[{0}] OSHttpHandlerList dump:", EngineID); |
312 | foreach (OSHttpHandler h in l) | 292 | foreach (OSHttpHandler h in l) |
313 | _LogDumpOSHttpHandler("OSHttpHandler", h); | 293 | _log.DebugFormat(" ", h.ToString()); |
314 | } | 294 | } |
315 | } | 295 | } |
316 | } | 296 | } |