From 3243e3153ddafee9ee663cac79c3da64153d0eb0 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 29 Oct 2008 20:19:08 +0000 Subject: [PATCH] * Added contentType parameter to new HttpListener.AddHandler() overload * Updated Simian to use the simplified HttpListener.AddHandler() overload git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@2317 52acb1d6-8a22-11de-b505-999d5b087335 --- OpenMetaverse/Capabilities/HttpServer.cs | 3 ++- Programs/Simian/Simian.cs | 32 +++--------------------- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/OpenMetaverse/Capabilities/HttpServer.cs b/OpenMetaverse/Capabilities/HttpServer.cs index 910c9c71..ed9f2174 100644 --- a/OpenMetaverse/Capabilities/HttpServer.cs +++ b/OpenMetaverse/Capabilities/HttpServer.cs @@ -86,10 +86,11 @@ namespace OpenMetaverse.Capabilities isRunning = false; } - public void AddHandler(string method, string path, HttpRequestCallback callback) + public void AddHandler(string method, string contentType, string path, HttpRequestCallback callback) { HttpRequestSignature signature = new HttpRequestSignature(); signature.Method = method; + signature.ContentType = contentType; signature.Path = path; AddHandler(new HttpRequestHandler(signature, callback)); } diff --git a/Programs/Simian/Simian.cs b/Programs/Simian/Simian.cs index 67e60150..9dfbc476 100644 --- a/Programs/Simian/Simian.cs +++ b/Programs/Simian/Simian.cs @@ -152,40 +152,16 @@ namespace Simian HttpServer = new HttpServer(HttpPort, ssl); // Login webpage HEAD request, used to check if the login webpage is alive - HttpRequestSignature signature = new HttpRequestSignature(); - signature.Method = "head"; - signature.ContentType = String.Empty; - signature.Path = "/loginpage"; - HttpServer.HttpRequestCallback callback = new HttpServer.HttpRequestCallback(LoginWebpageHeadHandler); - HttpServer.HttpRequestHandler handler = new HttpServer.HttpRequestHandler(signature, callback); - HttpServer.AddHandler(handler); + HttpServer.AddHandler("head", null, "^/loginpage", new HttpServer.HttpRequestCallback(LoginWebpageHeadHandler)); // Login webpage GET request, gets the login webpage data (purely aesthetic) - signature.Method = "get"; - signature.ContentType = String.Empty; - signature.Path = "/loginpage"; - callback = new HttpServer.HttpRequestCallback(LoginWebpageGetHandler); - handler.Signature = signature; - handler.Callback = callback; - HttpServer.AddHandler(handler); + HttpServer.AddHandler("get", null, "^/loginpage", new HttpServer.HttpRequestCallback(LoginWebpageGetHandler)); // Client XML-RPC login - signature.Method = "post"; - signature.ContentType = "text/xml"; - signature.Path = "/login"; - callback = new HttpServer.HttpRequestCallback(LoginXmlRpcPostHandler); - handler.Signature = signature; - handler.Callback = callback; - HttpServer.AddHandler(handler); + HttpServer.AddHandler("post", "text/xml", "^/login", new HttpServer.HttpRequestCallback(LoginXmlRpcPostHandler)); // Client LLSD login - signature.Method = "post"; - signature.ContentType = "application/xml"; - signature.Path = "/login"; - callback = new HttpServer.HttpRequestCallback(LoginLLSDPostHandler); - handler.Signature = signature; - handler.Callback = callback; - HttpServer.AddHandler(handler); + HttpServer.AddHandler("post", "application/xml", "^/login", new HttpServer.HttpRequestCallback(LoginLLSDPostHandler)); HttpServer.Start(); }