diff options
author | Dr Scofield | 2008-07-18 15:31:28 +0000 |
---|---|---|
committer | Dr Scofield | 2008-07-18 15:31:28 +0000 |
commit | 0ea73384d4506c83bcd9f721a13fd5be11d1cc33 (patch) | |
tree | 1645c02c6ee5f025fb7eab8800c94b293fe738ac /OpenSim/Framework/Servers/OSHttpXmlRpcHandler.cs | |
parent | remove all the odd quoting, on the off chance this was causing some (diff) | |
download | opensim-SC-0ea73384d4506c83bcd9f721a13fd5be11d1cc33.zip opensim-SC-0ea73384d4506c83bcd9f721a13fd5be11d1cc33.tar.gz opensim-SC-0ea73384d4506c83bcd9f721a13fd5be11d1cc33.tar.bz2 opensim-SC-0ea73384d4506c83bcd9f721a13fd5be11d1cc33.tar.xz |
simplifying OSHTtpHandler (a bit), adding query string matching,
adapting OSHttpXmlRpcHandler accordingly.
NOTE: this code is not live.
Diffstat (limited to 'OpenSim/Framework/Servers/OSHttpXmlRpcHandler.cs')
-rw-r--r-- | OpenSim/Framework/Servers/OSHttpXmlRpcHandler.cs | 79 |
1 files changed, 38 insertions, 41 deletions
diff --git a/OpenSim/Framework/Servers/OSHttpXmlRpcHandler.cs b/OpenSim/Framework/Servers/OSHttpXmlRpcHandler.cs index f9ce5b1..2c31cfd 100644 --- a/OpenSim/Framework/Servers/OSHttpXmlRpcHandler.cs +++ b/OpenSim/Framework/Servers/OSHttpXmlRpcHandler.cs | |||
@@ -51,48 +51,42 @@ namespace OpenSim.Framework.Servers | |||
51 | /// </summary> | 51 | /// </summary> |
52 | /// <returns>true if the handler is interested in the content; | 52 | /// <returns>true if the handler is interested in the content; |
53 | /// false otherwise</returns> | 53 | /// false otherwise</returns> |
54 | internal override OSHttpContentTypeChecker ContentTypeChecker | 54 | protected bool XmlRpcMethodMatch(OSHttpRequest req) |
55 | { | 55 | { |
56 | get | 56 | XmlRpcRequest xmlRpcRequest = null; |
57 | { | 57 | |
58 | return delegate(OSHttpRequest req) | 58 | // check whether req is already reified |
59 | // if not: reify (and post to whiteboard) | ||
60 | try | ||
61 | { | ||
62 | if (req.Whiteboard.ContainsKey("xmlrequest")) | ||
59 | { | 63 | { |
60 | XmlRpcRequest xmlRpcRequest = null; | 64 | xmlRpcRequest = req.Whiteboard["xmlrequest"] as XmlRpcRequest; |
61 | 65 | } | |
62 | // check whether req is already reified | 66 | else |
63 | // if not: reify (and post to whiteboard) | 67 | { |
64 | try | 68 | StreamReader body = new StreamReader(req.InputStream); |
65 | { | 69 | string requestBody = body.ReadToEnd(); |
66 | if (req.Whiteboard.ContainsKey("xmlrequest")) | 70 | xmlRpcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); |
67 | { | 71 | req.Whiteboard["xmlrequest"] = xmlRpcRequest; |
68 | xmlRpcRequest = req.Whiteboard["xmlrequest"] as XmlRpcRequest; | 72 | } |
69 | } | 73 | } |
70 | else | 74 | catch (XmlException) |
71 | { | 75 | { |
72 | StreamReader body = new StreamReader(req.InputStream); | 76 | _log.ErrorFormat("[OSHttpXmlRpcHandler] failed to deserialize XmlRpcRequest from {0}", req.ToString()); |
73 | string requestBody = body.ReadToEnd(); | 77 | return false; |
74 | xmlRpcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); | ||
75 | req.Whiteboard["xmlrequest"] = xmlRpcRequest; | ||
76 | } | ||
77 | } | ||
78 | catch (XmlException) | ||
79 | { | ||
80 | _log.ErrorFormat("[OSHttpXmlRpcHandler] failed to deserialize XmlRpcRequest from {0}", req.ToString()); | ||
81 | return false; | ||
82 | } | ||
83 | |||
84 | // check against methodName | ||
85 | if ((null != xmlRpcRequest) | ||
86 | && !String.IsNullOrEmpty(xmlRpcRequest.MethodName) | ||
87 | && xmlRpcRequest.MethodName == _methodName) | ||
88 | { | ||
89 | _log.DebugFormat("[OSHttpXmlRpcHandler] located handler {0} for {1}", _methodName, req.ToString()); | ||
90 | return true; | ||
91 | } | ||
92 | |||
93 | return false; | ||
94 | }; | ||
95 | } | 78 | } |
79 | |||
80 | // check against methodName | ||
81 | if ((null != xmlRpcRequest) | ||
82 | && !String.IsNullOrEmpty(xmlRpcRequest.MethodName) | ||
83 | && xmlRpcRequest.MethodName == _methodName) | ||
84 | { | ||
85 | _log.DebugFormat("[OSHttpXmlRpcHandler] located handler {0} for {1}", _methodName, req.ToString()); | ||
86 | return true; | ||
87 | } | ||
88 | |||
89 | return false; | ||
96 | } | 90 | } |
97 | 91 | ||
98 | // contains handler for processing XmlRpc Request | 92 | // contains handler for processing XmlRpc Request |
@@ -149,8 +143,11 @@ namespace OpenSim.Framework.Servers | |||
149 | XmlRpcResponse xmlRpcResponse; | 143 | XmlRpcResponse xmlRpcResponse; |
150 | string responseString; | 144 | string responseString; |
151 | 145 | ||
146 | // check whether we are interested in this request | ||
147 | if (!XmlRpcMethodMatch(request)) return OSHttpHandlerResult.Pass; | ||
148 | |||
149 | |||
152 | OSHttpResponse resp = new OSHttpResponse(request); | 150 | OSHttpResponse resp = new OSHttpResponse(request); |
153 | |||
154 | try | 151 | try |
155 | { | 152 | { |
156 | // reified XmlRpcRequest must still be on the whiteboard | 153 | // reified XmlRpcRequest must still be on the whiteboard |