From 5ced4eea0a12c64c4e1425f22bb7dd311463ebcd Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 10 Jul 2006 21:54:44 +0000 Subject: Header stuff git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4313 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_http.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/modules/m_http.cpp b/src/modules/m_http.cpp index 63ac802bd..d1088f3c0 100644 --- a/src/modules/m_http.cpp +++ b/src/modules/m_http.cpp @@ -68,6 +68,14 @@ class HttpSocket : public InspSocket { } + void SendHeaders() + { + struct tm *timeinfo = localtime(&TIME); + this->Write("HTTP/1.1 200 OK\r\nDate: "); + this->Write(asctime(timeinfo)); + this->Write("Server: InspIRCd/m_http.so/1.1\r\nContent-Length: 27\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n"); + } + virtual bool OnDataReady() { char* data = this->Read(); @@ -80,13 +88,28 @@ class HttpSocket : public InspSocket { /* Headers are complete */ InternalState = HTTP_SERVE_SEND_DATA; + SendHeaders(); + this->Write("

COWS.

"); - this->timeout_end = TIME; + /* This clever hax makes InspSocket think its + * in a connecting state, and time out 2 seconds + * from now. Most apache servers do this if the + * client doesnt close the connection as its + * supposed to. + */ + this->timeout_end = TIME + 2; this->SetState(I_CONNECTING); } + return true; + } + else + { + /* Bastard client closed the socket on us! + * Oh wait, theyre SUPPOSED to do that! + */ + return false; } - return true; } }; -- cgit v1.2.3