diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Servers/OSHttpServer.cs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/OSHttpServer.cs b/OpenSim/Framework/Servers/OSHttpServer.cs index 296f853..c022062 100644 --- a/OpenSim/Framework/Servers/OSHttpServer.cs +++ b/OpenSim/Framework/Servers/OSHttpServer.cs | |||
@@ -26,9 +26,11 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Net; | 30 | using System.Net; |
30 | using System.Net.Sockets; | 31 | using System.Net.Sockets; |
31 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Text.RegularExpressions; | ||
32 | using System.Threading; | 34 | using System.Threading; |
33 | using System.Security.Cryptography.X509Certificates; | 35 | using System.Security.Cryptography.X509Certificates; |
34 | using log4net; | 36 | using log4net; |
@@ -38,6 +40,39 @@ using HttpListener = HttpServer.HttpListener; | |||
38 | 40 | ||
39 | namespace OpenSim.Framework.Servers | 41 | namespace OpenSim.Framework.Servers |
40 | { | 42 | { |
43 | /// <sumary> | ||
44 | /// Any OSHttpHandler must return one of the following results: | ||
45 | /// <list type = "table"> | ||
46 | /// <listheader> | ||
47 | /// <term>result code</term> | ||
48 | /// <description>meaning</description> | ||
49 | /// </listheader> | ||
50 | /// <item> | ||
51 | /// <term>Pass</term> | ||
52 | /// <description>handler did not process the request</request> | ||
53 | /// </item> | ||
54 | /// <item> | ||
55 | /// <term>Handled</term> | ||
56 | /// <description>handler did process the request, OSHttpServer | ||
57 | /// can clean up and close the request</request> | ||
58 | /// </item> | ||
59 | /// <item> | ||
60 | /// <term>Detached</term> | ||
61 | /// <description>handler handles the request, OSHttpServer | ||
62 | /// can forget about the request and should not touch it as | ||
63 | /// the handler has taken control</request> | ||
64 | /// </item> | ||
65 | /// </list> | ||
66 | /// </summary> | ||
67 | public enum OSHttpHandlerResult | ||
68 | { | ||
69 | Pass, | ||
70 | Handled, | ||
71 | Detached, | ||
72 | } | ||
73 | |||
74 | public delegate OSHttpHandlerResult OSHttpHandler(OSHttpRequest request); | ||
75 | |||
41 | /// <summary> | 76 | /// <summary> |
42 | /// OSHttpServer provides an HTTP server bound to a specific | 77 | /// OSHttpServer provides an HTTP server bound to a specific |
43 | /// port. When instantiated with just address and port it uses | 78 | /// port. When instantiated with just address and port it uses |
@@ -136,6 +171,7 @@ namespace OpenSim.Framework.Servers | |||
136 | } | 171 | } |
137 | 172 | ||
138 | /// <summary> | 173 | /// <summary> |
174 | /// Engine keeps the HTTP server running. | ||
139 | /// </summary> | 175 | /// </summary> |
140 | private void Engine() | 176 | private void Engine() |
141 | { | 177 | { |
@@ -146,7 +182,24 @@ namespace OpenSim.Framework.Servers | |||
146 | } | 182 | } |
147 | } | 183 | } |
148 | 184 | ||
185 | protected Dictionary<OSHttpHandler, Regex> Handler2Path = new Dictionary<OSHttpHandler, Regex>(); | ||
186 | protected Dictionary<OSHttpHandler, Dictionary<string, Regex>> Handler2Headers = | ||
187 | new Dictionary<OSHttpHandler, Dictionary<string, Regex>>(); | ||
149 | 188 | ||
189 | /// <summary> | ||
190 | /// Add an HTTP request handler. | ||
191 | /// </summary> | ||
192 | /// <param name="handler">OSHttpHandler delegate</param> | ||
193 | /// <param name="path">regex object for path matching</parm> | ||
194 | /// <param name="headers">dictionary containing header names | ||
195 | /// and regular expressions to match against header values</param> | ||
196 | public void AddHandler(OSHttpHandler handler, Regex path, Dictionary<string, Regex> headers) | ||
197 | { | ||
198 | lock (Handler2Headers) | ||
199 | { | ||
200 | |||
201 | } | ||
202 | } | ||
150 | 203 | ||
151 | } | 204 | } |
152 | } | 205 | } |