From 7e843c22e16c81054bad18073d24fe1a07026431 Mon Sep 17 00:00:00 2001 From: danieldg Date: Thu, 8 Oct 2009 23:29:21 +0000 Subject: Update Event and Request APIs git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11808 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_httpd.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/modules/m_httpd.cpp') diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index e9d05d3e5..9d1acfbb9 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -313,13 +313,12 @@ class HttpServerSocket : public BufferedSocket else { claimed = false; - HTTPRequest httpr(request_type,uri,&headers,this,ip,postdata); - Event acl((char*)&httpr, (Module*)HttpModule, "httpd_acl"); + HTTPRequest acl((Module*)HttpModule, "httpd_acl", request_type, uri, &headers, this, ip, postdata); acl.Send(); if (!claimed) { - Event e((char*)&httpr, (Module*)HttpModule, "httpd_url"); - e.Send(); + HTTPRequest url((Module*)HttpModule, "httpd_url", request_type, uri, &headers, this, ip, postdata); + url.Send(); if (!claimed) { SendHTTPError(404); @@ -384,7 +383,7 @@ class ModuleHttpServer : public Module index = new FileReader(indexfile); if (!index->Exists()) throw ModuleException("Can't read index file: "+indexfile); - http = new HttpListener(index, port, (char *)bindip.c_str()); // XXX this cast SUCKS. + http = new HttpListener(index, port, bindip); httplisteners.push_back(http); } } @@ -392,17 +391,15 @@ class ModuleHttpServer : public Module ModuleHttpServer() { ReadConfig(); HttpModule = this; - Implementation eventlist[] = { I_OnRequest }; - ServerInstance->Modules->Attach(eventlist, this, 1); } - virtual const char* OnRequest(Request* request) + void OnRequest(Request& request) { + if (strcmp(request.id, "HTTP-DOC") != 0) + return; + HTTPDocumentResponse& resp = static_cast(request); claimed = true; - HTTPDocument* doc = (HTTPDocument*)request->GetData(); - HttpServerSocket* sock = (HttpServerSocket*)doc->sock; - sock->Page(doc->GetDocument(), doc->GetResponseCode(), &doc->headers); - return NULL; + resp.src.sock->Page(resp.document, resp.responsecode, &resp.headers); } -- cgit v1.2.3