summaryrefslogtreecommitdiff
path: root/includes/HttpServer.h
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-11-18 22:52:12 -0800
committerPixel <pixel@nobis-crew.org>2011-11-18 22:52:12 -0800
commit0f0db0ee56b69d580fe66528a379fb08d714bf4d (patch)
treebf55d752c095838644e50b9bd762538cd9eaa447 /includes/HttpServer.h
parent52f7b28073501242dacd6409bb649fc2182cc777 (diff)
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.
Diffstat (limited to 'includes/HttpServer.h')
-rw-r--r--includes/HttpServer.h12
1 files changed, 5 insertions, 7 deletions
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 <Exceptions.h>
#include <Threads.h>
#include <Handle.h>
+#include <Http.h>
namespace Balau {
@@ -17,19 +18,16 @@ class HttpWorker;
class HttpServer {
public:
- typedef std::map<String, String> StringMap;
- typedef std::map<String, IO<Handle> > 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<Regex::Captures, Regex::Captures> ActionMatches;
- ActionMatches matches(const char * uri, const char * host);
+ typedef std::pair<Regex::Captures, Regex::Captures> 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<Handle> out, StringMap & vars, StringMap & headers, FileList & files) = 0;
+ virtual bool Do(HttpServer * server, Http::Request & req, ActionMatch & match, IO<Handle> 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<Action *, Action::ActionMatches> ActionFound;
+ typedef std::pair<Action *, Action::ActionMatch> ActionFound;
ActionFound findAction(const char * uri, const char * host);
private:
bool m_started;