diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-02-12 16:35:02 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-02-12 16:35:02 +0100 |
commit | ae6967b8b30ebc956e3158127ecba5d01dc09204 (patch) | |
tree | b0940ea9cbd75acfdaa655b3a9975f67e3f8ae48 /src/modules/m_httpd.cpp | |
parent | a7aa76f17ac22897e08558f0f78d891d3d4f7de6 (diff) | |
parent | 7918febc630d7d6f94fda1a918fe7b98c2d0e742 (diff) |
Merge branch 'master+crossmodevents'
Diffstat (limited to 'src/modules/m_httpd.cpp')
-rw-r--r-- | src/modules/m_httpd.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index bbd9f1275..e09ca3fa2 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -29,8 +29,9 @@ class ModuleHttpServer; static ModuleHttpServer* HttpModule; -static bool claimed; static insp::intrusive_list<HttpServerSocket> sockets; +static Events::ModuleEventProvider* aclevprov; +static Events::ModuleEventProvider* reqevprov; /** HTTP socket states */ @@ -322,14 +323,14 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru { InternalState = HTTP_SERVE_SEND_DATA; - claimed = false; - HTTPRequest acl((Module*)HttpModule, "httpd_acl", request_type, uri, &headers, this, ip, postdata); - acl.Send(); - if (!claimed) + ModResult MOD_RESULT; + HTTPRequest acl(request_type, uri, &headers, this, ip, postdata); + FIRST_MOD_RESULT_CUSTOM(*aclevprov, HTTPACLEventListener, OnHTTPACLCheck, MOD_RESULT, (acl)); + if (MOD_RESULT != MOD_RES_DENY) { - HTTPRequest url((Module*)HttpModule, "httpd_url", request_type, uri, &headers, this, ip, postdata); - url.Send(); - if (!claimed) + HTTPRequest url(request_type, uri, &headers, this, ip, postdata); + FIRST_MOD_RESULT_CUSTOM(*reqevprov, HTTPRequestEventListener, OnHTTPRequest, MOD_RESULT, (url)); + if (MOD_RESULT == MOD_RES_PASSTHRU) { SendHTTPError(404); } @@ -363,7 +364,6 @@ class HTTPdAPIImpl : public HTTPdAPIBase void SendResponse(HTTPDocumentResponse& resp) CXX11_OVERRIDE { - claimed = true; resp.src.sock->Page(resp.document, resp.responsecode, &resp.headers); } }; @@ -372,11 +372,17 @@ class ModuleHttpServer : public Module { HTTPdAPIImpl APIImpl; unsigned int timeoutsec; + Events::ModuleEventProvider acleventprov; + Events::ModuleEventProvider reqeventprov; public: ModuleHttpServer() : APIImpl(this) + , acleventprov(this, "event/http-acl") + , reqeventprov(this, "event/http-request") { + aclevprov = &acleventprov; + reqevprov = &reqeventprov; } void init() CXX11_OVERRIDE |