aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/OSHttpServer.cs
diff options
context:
space:
mode:
authorDr Scofield2008-06-27 09:29:41 +0000
committerDr Scofield2008-06-27 09:29:41 +0000
commit63a1a2739a28b32dde60f01fce2fbd5149ede0ad (patch)
tree60f8badb7b93a80f2102f6cac6494e075ab79c07 /OpenSim/Framework/Servers/OSHttpServer.cs
parentMantis#1612. Thank you, kindly, Matth for a patch that: (diff)
downloadopensim-SC_OLD-63a1a2739a28b32dde60f01fce2fbd5149ede0ad.zip
opensim-SC_OLD-63a1a2739a28b32dde60f01fce2fbd5149ede0ad.tar.gz
opensim-SC_OLD-63a1a2739a28b32dde60f01fce2fbd5149ede0ad.tar.bz2
opensim-SC_OLD-63a1a2739a28b32dde60f01fce2fbd5149ede0ad.tar.xz
status: work in progress, non-functional
having OSHttpHandler as a delegate was not too hot, i'm refactoring it into an interface.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Servers/OSHttpServer.cs66
1 files changed, 25 insertions, 41 deletions
diff --git a/OpenSim/Framework/Servers/OSHttpServer.cs b/OpenSim/Framework/Servers/OSHttpServer.cs
index c022062..169ce13 100644
--- a/OpenSim/Framework/Servers/OSHttpServer.cs
+++ b/OpenSim/Framework/Servers/OSHttpServer.cs
@@ -40,39 +40,6 @@ using HttpListener = HttpServer.HttpListener;
40 40
41namespace OpenSim.Framework.Servers 41namespace OpenSim.Framework.Servers
42{ 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
76 /// <summary> 43 /// <summary>
77 /// OSHttpServer provides an HTTP server bound to a specific 44 /// OSHttpServer provides an HTTP server bound to a specific
78 /// port. When instantiated with just address and port it uses 45 /// port. When instantiated with just address and port it uses
@@ -81,7 +48,7 @@ namespace OpenSim.Framework.Servers
81 /// </summary> 48 /// </summary>
82 public class OSHttpServer 49 public class OSHttpServer
83 { 50 {
84 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
85 52
86 // underlying HttpServer.HttpListener 53 // underlying HttpServer.HttpListener
87 protected HttpListener _listener; 54 protected HttpListener _listener;
@@ -117,6 +84,22 @@ namespace OpenSim.Framework.Servers
117 } 84 }
118 85
119 /// <summary> 86 /// <summary>
87 /// List of registered OSHttpHandlers for this OSHttpServer instance.
88 /// </summary>
89 protected List<OSHttpHandler> _httpHandlers = new List<OSHttpHandler>();
90 public List<OSHttpHandler> OSHttpHandlers
91 {
92 get
93 {
94 lock (_httpHandlers)
95 {
96 return new List<OSHttpHandler>(_httpHandlers);
97 }
98 }
99 }
100
101
102 /// <summary>
120 /// Instantiate an HTTP server. 103 /// Instantiate an HTTP server.
121 /// </summary> 104 /// </summary>
122 public OSHttpServer(IPAddress address, int port, int poolSize) 105 public OSHttpServer(IPAddress address, int port, int poolSize)
@@ -182,9 +165,6 @@ namespace OpenSim.Framework.Servers
182 } 165 }
183 } 166 }
184 167
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>>();
188 168
189 /// <summary> 169 /// <summary>
190 /// Add an HTTP request handler. 170 /// Add an HTTP request handler.
@@ -193,13 +173,17 @@ namespace OpenSim.Framework.Servers
193 /// <param name="path">regex object for path matching</parm> 173 /// <param name="path">regex object for path matching</parm>
194 /// <param name="headers">dictionary containing header names 174 /// <param name="headers">dictionary containing header names
195 /// and regular expressions to match against header values</param> 175 /// and regular expressions to match against header values</param>
196 public void AddHandler(OSHttpHandler handler, Regex path, Dictionary<string, Regex> headers) 176 public void AddHandler(OSHttpHandler handler)
197 { 177 {
198 lock (Handler2Headers) 178 lock (_httpHandlers)
199 { 179 {
200 180 if (_httpHandlers.Contains(handler))
181 {
182 _log.DebugFormat("[OSHttpServer] attempt to add already existing handler ignored");
183 return;
184 }
185 _httpHandlers.Add(handler);
201 } 186 }
202 } 187 }
203
204 } 188 }
205} 189}