summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-10 21:54:44 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-10 21:54:44 +0000
commit5ced4eea0a12c64c4e1425f22bb7dd311463ebcd (patch)
tree0e56e80eaabc0b4ca388624373b9914e10e37075 /src
parente3d229ec106cde915669aed8dc076dde2fafb2fa (diff)
Header stuff
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4313 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_http.cpp27
1 files changed, 25 insertions, 2 deletions
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("<HTML><H1>COWS.</H1></HTML>");
- 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;
}
};