From 0f0db0ee56b69d580fe66528a379fb08d714bf4d Mon Sep 17 00:00:00 2001 From: Pixel Date: Fri, 18 Nov 2011 22:52:12 -0800 Subject: Starting to re-organize the HTTP code a bit. Sharing code between the server and a potential client makes sense. Also packing requests and responses into structures / classes is probably a good idea. --- includes/HttpServer.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'includes/HttpServer.h') diff --git a/includes/HttpServer.h b/includes/HttpServer.h index c2e8992..f78a816 100644 --- a/includes/HttpServer.h +++ b/includes/HttpServer.h @@ -9,6 +9,7 @@ #include #include #include +#include namespace Balau { @@ -17,19 +18,16 @@ class HttpWorker; class HttpServer { public: - typedef std::map StringMap; - typedef std::map > FileList; - class Action { public: Action(Regex & regex, Regex & host = Regexes::any) : m_regex(regex), m_host(host), m_refCount(0) { } ~Action() { Assert(m_refCount == 0); } - typedef std::pair ActionMatches; - ActionMatches matches(const char * uri, const char * host); + typedef std::pair ActionMatch; + ActionMatch matches(const char * uri, const char * host); void unref() { if (Atomic::Decrement(&m_refCount) == 0) delete this; } void ref() { Atomic::Increment(&m_refCount); } void registerMe(HttpServer * server) { server->registerAction(this); } - virtual bool Do(HttpServer * server, ActionMatches & m, IO out, StringMap & vars, StringMap & headers, FileList & files) = 0; + virtual bool Do(HttpServer * server, Http::Request & req, ActionMatch & match, IO out) = 0; private: Regex m_regex, m_host; volatile int m_refCount; @@ -43,7 +41,7 @@ class HttpServer { void setLocal(const char * local) { Assert(!m_started); m_local = local; } void registerAction(Action * action); void flushAllActions(); - typedef std::pair ActionFound; + typedef std::pair ActionFound; ActionFound findAction(const char * uri, const char * host); private: bool m_started; -- cgit v1.2.3