From 744b44dc8b6aef3647e6009a3de219bf39a9a781 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Thu, 26 Jun 2008 16:10:04 +0000 Subject: WORK-IN-PRGRESS: beware of falling pieces and shifting tectonic plates: starting AddHandler() code. --- OpenSim/Framework/Servers/OSHttpServer.cs | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'OpenSim/Framework/Servers') 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 @@ */ using System; +using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Reflection; +using System.Text.RegularExpressions; using System.Threading; using System.Security.Cryptography.X509Certificates; using log4net; @@ -38,6 +40,39 @@ using HttpListener = HttpServer.HttpListener; namespace OpenSim.Framework.Servers { + /// + /// Any OSHttpHandler must return one of the following results: + /// + /// + /// result code + /// meaning + /// + /// + /// Pass + /// handler did not process the request + /// + /// + /// Handled + /// handler did process the request, OSHttpServer + /// can clean up and close the request + /// + /// + /// Detached + /// handler handles the request, OSHttpServer + /// can forget about the request and should not touch it as + /// the handler has taken control + /// + /// + /// + public enum OSHttpHandlerResult + { + Pass, + Handled, + Detached, + } + + public delegate OSHttpHandlerResult OSHttpHandler(OSHttpRequest request); + /// /// OSHttpServer provides an HTTP server bound to a specific /// port. When instantiated with just address and port it uses @@ -136,6 +171,7 @@ namespace OpenSim.Framework.Servers } /// + /// Engine keeps the HTTP server running. /// private void Engine() { @@ -146,7 +182,24 @@ namespace OpenSim.Framework.Servers } } + protected Dictionary Handler2Path = new Dictionary(); + protected Dictionary> Handler2Headers = + new Dictionary>(); + /// + /// Add an HTTP request handler. + /// + /// OSHttpHandler delegate + /// regex object for path matching + /// dictionary containing header names + /// and regular expressions to match against header values + public void AddHandler(OSHttpHandler handler, Regex path, Dictionary headers) + { + lock (Handler2Headers) + { + + } + } } } -- cgit v1.1