summaryrefslogtreecommitdiff
path: root/src/modules/m_httpd.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-08 23:29:21 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-08 23:29:21 +0000
commit7e843c22e16c81054bad18073d24fe1a07026431 (patch)
tree44ca0213c7d7a80270b993fec1fbed275ec56424 /src/modules/m_httpd.cpp
parentc440038736f749a56dbac1badee5b2f099286117 (diff)
Update Event and Request APIs
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11808 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_httpd.cpp')
-rw-r--r--src/modules/m_httpd.cpp21
1 files changed, 9 insertions, 12 deletions
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<HTTPDocumentResponse&>(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);
}