aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/OSHttpHandler.cs
diff options
context:
space:
mode:
authorDr Scofield2008-07-17 12:54:15 +0000
committerDr Scofield2008-07-17 12:54:15 +0000
commited4241583f60ff43209b7c6e7c966efc6d96280e (patch)
tree8a82b31230b12ea26841373b85ca9646c4ecef82 /OpenSim/Framework/Servers/OSHttpHandler.cs
parentadded index to ParentID on prims, as this is sorted on for prim loading. (diff)
downloadopensim-SC_OLD-ed4241583f60ff43209b7c6e7c966efc6d96280e.zip
opensim-SC_OLD-ed4241583f60ff43209b7c6e7c966efc6d96280e.tar.gz
opensim-SC_OLD-ed4241583f60ff43209b7c6e7c966efc6d96280e.tar.bz2
opensim-SC_OLD-ed4241583f60ff43209b7c6e7c966efc6d96280e.tar.xz
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).
Diffstat (limited to 'OpenSim/Framework/Servers/OSHttpHandler.cs')
-rw-r--r--OpenSim/Framework/Servers/OSHttpHandler.cs99
1 files changed, 79 insertions, 20 deletions
diff --git a/OpenSim/Framework/Servers/OSHttpHandler.cs b/OpenSim/Framework/Servers/OSHttpHandler.cs
index a9f42f3..8b65438 100644
--- a/OpenSim/Framework/Servers/OSHttpHandler.cs
+++ b/OpenSim/Framework/Servers/OSHttpHandler.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO;
30using System.Text.RegularExpressions; 31using System.Text.RegularExpressions;
31 32
32namespace OpenSim.Framework.Servers 33namespace OpenSim.Framework.Servers
@@ -43,16 +44,10 @@ namespace OpenSim.Framework.Servers
43 /// <description>handler did not process the request</request> 44 /// <description>handler did not process the request</request>
44 /// </item> 45 /// </item>
45 /// <item> 46 /// <item>
46 /// <term>Handled</term> 47 /// <term>Done</term>
47 /// <description>handler did process the request, OSHttpServer 48 /// <description>handler did process the request, OSHttpServer
48 /// can clean up and close the request</request> 49 /// can clean up and close the request</request>
49 /// </item> 50 /// </item>
50 /// <item>
51 /// <term>Detached</term>
52 /// <description>handler handles the request, OSHttpServer
53 /// can forget about the request and should not touch it as
54 /// the handler has taken control</request>
55 /// </item>
56 /// </list> 51 /// </list>
57 /// </summary> 52 /// </summary>
58 public enum OSHttpHandlerResult 53 public enum OSHttpHandlerResult
@@ -71,26 +66,41 @@ namespace OpenSim.Framework.Servers
71 /// false otherwise</returns> 66 /// false otherwise</returns>
72 public delegate bool OSHttpContentTypeChecker(OSHttpRequest req); 67 public delegate bool OSHttpContentTypeChecker(OSHttpRequest req);
73 68
74 public interface OSHttpHandler 69 public abstract class OSHttpHandler
75 { 70 {
76 /// <summary> 71 /// <summary>
77 /// Regular expression used to match against path of incoming 72 /// Regular expression used to match against method of
78 /// HTTP request. If you want to match any string either use 73 /// the incoming HTTP request. If you want to match any string
79 /// '.*' or null. To match for the emtpy string use '^$' 74 /// either use '.*' or null. To match on the empty string use
75 /// '^$'.
80 /// </summary> 76 /// </summary>
81 Regex Path 77 public virtual Regex Method
82 { 78 {
83 get; 79 get { return _method; }
84 } 80 }
81 protected Regex _method;
82
83 /// <summary>
84 /// Regular expression used to match against path of the
85 /// incoming HTTP request. If you want to match any string
86 /// either use '.*' or null. To match on the emtpy string use
87 /// '^$'.
88 /// </summary>
89 public virtual Regex Path
90 {
91 get { return _path; }
92 }
93 protected Regex _path;
85 94
86 /// <summary> 95 /// <summary>
87 /// Dictionary of (header name, regular expression) tuples, 96 /// Dictionary of (header name, regular expression) tuples,
88 /// allowing us to match on HTTP header fields. 97 /// allowing us to match on HTTP header fields.
89 /// </summary> 98 /// </summary>
90 Dictionary<string, Regex> Headers 99 public virtual Dictionary<string, Regex> Headers
91 { 100 {
92 get; 101 get { return _headers; }
93 } 102 }
103 protected Dictionary<string, Regex> _headers;
94 104
95 /// <summary> 105 /// <summary>
96 /// Dictionary of (header name, regular expression) tuples, 106 /// Dictionary of (header name, regular expression) tuples,
@@ -101,10 +111,11 @@ namespace OpenSim.Framework.Servers
101 /// (trivial) changes to HttpServer.HttpListener that have not 111 /// (trivial) changes to HttpServer.HttpListener that have not
102 /// been implemented. 112 /// been implemented.
103 /// </remarks> 113 /// </remarks>
104 Regex IPEndPointWhitelist 114 public virtual Regex IPEndPointWhitelist
105 { 115 {
106 get; 116 get { return _ipEndPointRegex; }
107 } 117 }
118 protected Regex _ipEndPointRegex;
108 119
109 120
110 /// <summary> 121 /// <summary>
@@ -114,11 +125,59 @@ namespace OpenSim.Framework.Servers
114 /// </summary> 125 /// </summary>
115 /// <returns>true if the handler is interested in the content; 126 /// <returns>true if the handler is interested in the content;
116 /// false otherwise</returns> 127 /// false otherwise</returns>
117 OSHttpContentTypeChecker ContentTypeChecker 128 internal virtual OSHttpContentTypeChecker ContentTypeChecker
118 { 129 {
119 get; 130 get { return null; }
131 }
132
133 /// <summary>
134 /// Base class constructor.
135 /// </summary>
136 /// <param name="path">null or path regex</param>
137 /// <param name="headers">null or dictionary of header
138 /// regexs</param>
139 /// <param name="contentType">null or content type
140 /// regex</param>
141 /// <param name="whitelist">null or IP address regex</param>
142 public OSHttpHandler(Regex method, Regex path, Dictionary<string, Regex> headers, Regex contentType, Regex whitelist)
143 {
144 _method = method;
145 _path = path;
146 _ipEndPointRegex = whitelist;
147
148 if (null == _headers && null != contentType)
149 {
150 _headers = new Dictionary<string, Regex>();
151 _headers.Add("content-type", contentType);
152 }
120 } 153 }
121 154
122 OSHttpHandlerResult Process(OSHttpRequest request); 155
156 /// <summary>
157 /// Process an incoming OSHttpRequest that matched our
158 /// requirements.
159 /// </summary>
160 /// <returns>
161 /// OSHttpHandlerResult.Pass if we are after all not
162 /// interested in the request; OSHttpHandlerResult.Done if we
163 /// did process the request.
164 /// </returns>
165 public abstract OSHttpHandlerResult Process(OSHttpRequest request);
166
167 public override string ToString()
168 {
169 StringWriter sw = new StringWriter();
170 sw.WriteLine("{0}", base.ToString());
171 sw.WriteLine(" method regex {0}", null == Method ? "null" : Method.ToString());
172 sw.WriteLine(" path regex {0}", null == Path ? "null": Path.ToString());
173 foreach (string tag in Headers.Keys)
174 {
175 sw.WriteLine(" header {0} : {1}", tag, Headers[tag].ToString());
176 }
177 sw.WriteLine(" IP whitelist {0}", null == IPEndPointWhitelist ? "null" : IPEndPointWhitelist.ToString());
178 sw.WriteLine();
179 sw.Close();
180 return sw.ToString();
181 }
123 } 182 }
124} \ No newline at end of file 183} \ No newline at end of file