summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-08 22:15:00 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-08 22:15:00 +0000
commit2425244549a45295168b1958b9d599e5e286e629 (patch)
tree7f1f351a878d139bbe9860298003c4e167dadc9a /src/modules
parent6f43a18a8a4617423c2c757db35fbf96c67e3798 (diff)
Make this nicer, rely on the last write event after the Write() that sends all the data, not on a timer
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9671 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_httpd.cpp22
-rw-r--r--src/modules/m_httpd_stats.cpp1
2 files changed, 15 insertions, 8 deletions
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp
index ea7819023..4b0177ef0 100644
--- a/src/modules/m_httpd.cpp
+++ b/src/modules/m_httpd.cpp
@@ -46,7 +46,6 @@ class HttpServerSocket : public BufferedSocket
std::string request_type;
std::string uri;
std::string http_version;
- bool keepalive;
public:
@@ -55,7 +54,7 @@ class HttpServerSocket : public BufferedSocket
InternalState = HTTP_LISTEN;
}
- HttpServerSocket(InspIRCd* SI, int newfd, char* ip, FileReader* ind) : BufferedSocket(SI, newfd, ip), index(ind), postsize(0), keepalive(false)
+ HttpServerSocket(InspIRCd* SI, int newfd, char* ip, FileReader* ind) : BufferedSocket(SI, newfd, ip), index(ind), postsize(0)
{
InternalState = HTTP_SERVE_WAIT_REQUEST;
}
@@ -266,6 +265,7 @@ class HttpServerSocket : public BufferedSocket
if (request_type.empty() || uri.empty() || http_version.empty())
{
SendHTTPError(400);
+ Instance->SE->WantWrite(this);
return;
}
@@ -279,6 +279,7 @@ class HttpServerSocket : public BufferedSocket
if ((fieldsep == std::string::npos) || (fieldsep == 0) || (fieldsep == cheader.length() - 1))
{
SendHTTPError(400);
+ Instance->SE->WantWrite(this);
return;
}
@@ -295,12 +296,10 @@ class HttpServerSocket : public BufferedSocket
if ((http_version != "HTTP/1.1") && (http_version != "HTTP/1.0"))
{
SendHTTPError(505);
+ Instance->SE->WantWrite(this);
return;
}
-
- if (strcasecmp(headers.GetHeader("Connection").c_str(), "keep-alive") == 0)
- keepalive = true;
-
+
if (headers.IsSet("Content-Length") && (postsize = atoi(headers.GetHeader("Content-Length").c_str())) != 0)
{
InternalState = HTTP_SERVE_RECV_POSTDATA;
@@ -334,6 +333,7 @@ class HttpServerSocket : public BufferedSocket
HTTPHeaders empty;
SendHeaders(index->ContentSize(), 200, empty);
this->Write(index->Contents());
+ Instance->SE->WantWrite(this);
}
else
{
@@ -344,16 +344,22 @@ class HttpServerSocket : public BufferedSocket
if (!claimed)
{
SendHTTPError(404);
+ Instance->SE->WantWrite(this);
}
}
}
+
+ bool OnWriteReady()
+ {
+ return false;
+ }
+
void Page(std::stringstream* n, int response, HTTPHeaders *hheaders)
{
SendHeaders(n->str().length(), response, *hheaders);
this->Write(n->str());
- Instance->SE->DelFd(this);
- this->Close();
+ Instance->SE->WantWrite(this);
}
};
diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp
index 157f772c1..d95824c83 100644
--- a/src/modules/m_httpd_stats.cpp
+++ b/src/modules/m_httpd_stats.cpp
@@ -94,6 +94,7 @@ class ModuleHttpStats : public Module
if (event->GetEventID() == "httpd_url")
{
+ ServerInstance->Logs->Log("m_http_stats", DEBUG,"Handling httpd event");
HTTPRequest* http = (HTTPRequest*)event->GetData();
if ((http->GetURI() == "/stats") || (http->GetURI() == "/stats/"))