From ed4241583f60ff43209b7c6e7c966efc6d96280e Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Thu, 17 Jul 2008 12:54:15 +0000 Subject: morphing OSHttpHandler interface into an abstract base class. adding HTTP method matching support. adapting OSHttpXmlRpcHandler accordingly. dropping OSHttpXmlProcessor delegate in favour of good old XmlRpcMethodHandler delegate (was the same signature). --- OpenSim/Framework/Servers/OSHttpXmlRpcHandler.cs | 60 ++++-------------------- 1 file changed, 10 insertions(+), 50 deletions(-) (limited to 'OpenSim/Framework/Servers/OSHttpXmlRpcHandler.cs') diff --git a/OpenSim/Framework/Servers/OSHttpXmlRpcHandler.cs b/OpenSim/Framework/Servers/OSHttpXmlRpcHandler.cs index 4205547..f9ce5b1 100644 --- a/OpenSim/Framework/Servers/OSHttpXmlRpcHandler.cs +++ b/OpenSim/Framework/Servers/OSHttpXmlRpcHandler.cs @@ -45,49 +45,13 @@ namespace OpenSim.Framework.Servers private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// - /// Regular expression used to match against path of incoming - /// HTTP request. If you want to match any string either use - /// '.*' or null. To match for the emtpy string use '^$' - /// - public Regex Path - { - get { return _pathsRegex; } - } - private Regex _pathsRegex; - - /// - /// Dictionary of (header name, regular expression) tuples, - /// allowing us to match on HTTP header fields. - /// - public Dictionary Headers - { - get { return _headers; } - } - private Dictionary _headers; - - /// - /// Regex to whitelist IP end points. A null value disables - /// checking of IP end points. - /// - /// - /// This feature is currently not implemented as it requires - /// (trivial) changes to HttpServer.HttpListener that have not - /// been implemented. - /// - public Regex IPEndPointWhitelist - { - get { return _ipEndPointRegex; } - } - private Regex _ipEndPointRegex; - - /// /// An OSHttpHandler that matches on the "content-type" header can /// supply an OSHttpContentTypeChecker delegate which will be /// invoked by the request matcher in OSHttpRequestPump. /// /// true if the handler is interested in the content; /// false otherwise - public OSHttpContentTypeChecker ContentTypeChecker + internal override OSHttpContentTypeChecker ContentTypeChecker { get { @@ -132,7 +96,7 @@ namespace OpenSim.Framework.Servers } // contains handler for processing XmlRpc Request - private OSHttpXmlRpcProcessor _handler; + private XmlRpcMethod _handler; // contains XmlRpc method name private string _methodName; @@ -141,7 +105,7 @@ namespace OpenSim.Framework.Servers /// /// Instantiate an XmlRpc handler. /// - /// OSHttpXmlRpcProcessor + /// XmlRpcMethod /// delegate /// XmlRpc method name /// XmlRpc path prefix (regular expression) @@ -154,28 +118,24 @@ namespace OpenSim.Framework.Servers /// can be null, in which case they are not taken into account /// when the handler is being looked up. /// - public OSHttpXmlRpcHandler(OSHttpXmlRpcProcessor handler, string methodName, Regex path, + public OSHttpXmlRpcHandler(XmlRpcMethod handler, string methodName, Regex path, Dictionary headers, Regex whitelist) + : base(new Regex(@"^POST$", RegexOptions.IgnoreCase | RegexOptions.Compiled), path, headers, + new Regex(@"^(text|application)/xml", RegexOptions.IgnoreCase | RegexOptions.Compiled), + whitelist) { _handler = handler; - _pathsRegex = path; _methodName = methodName; - - if (null == _headers) _headers = new Dictionary(); - _headers.Add("content-type", new Regex(@"^(text|application)/xml", RegexOptions.IgnoreCase | - RegexOptions.Compiled)); - - _ipEndPointRegex = whitelist; } /// /// Instantiate an XmlRpc handler. /// - /// OSHttpXmlRpcProcessor + /// XmlRpcMethod /// delegate /// XmlRpc method name - public OSHttpXmlRpcHandler(OSHttpXmlRpcProcessor handler, string methodName) + public OSHttpXmlRpcHandler(XmlRpcMethod handler, string methodName) : this(handler, methodName, null, null, null) { } @@ -184,7 +144,7 @@ namespace OpenSim.Framework.Servers /// /// Invoked by OSHttpRequestPump. /// - public OSHttpHandlerResult Process(OSHttpRequest request) + public override OSHttpHandlerResult Process(OSHttpRequest request) { XmlRpcResponse xmlRpcResponse; string responseString; -- cgit v1.1