X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_httpd.cpp;h=e09ca3fa2c03c604f644736e7c839065ff08be00;hb=76608ff23d515fbf5fcdbdc17b7f261339b2a276;hp=0dd028924882a13a7ac1ec63eb31262489e44490;hpb=96dd0a52d93219a214130c18fe34bb81ce5acdbd;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index 0dd028924..e09ca3fa2 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -29,9 +29,9 @@ class ModuleHttpServer; static ModuleHttpServer* HttpModule; -static bool claimed; static insp::intrusive_list sockets; static Events::ModuleEventProvider* aclevprov; +static Events::ModuleEventProvider* reqevprov; /** HTTP socket states */ @@ -323,15 +323,14 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru { InternalState = HTTP_SERVE_SEND_DATA; - claimed = false; ModResult MOD_RESULT; - HTTPRequest acl((Module*)HttpModule, "httpd_acl", request_type, uri, &headers, this, ip, postdata); + 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); } @@ -365,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); } }; @@ -375,13 +373,16 @@ 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