summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-09-14 11:35:43 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-09-14 11:35:43 +0000
commit0f66106f8c6581ff47249b5ea9dde4157a395263 (patch)
tree5aa0dcbf6dbb887aa7eb27d21dd35765f8e1d4d6 /src
parenta19512aff37629676ba3d8851178f9d0a7c8d603 (diff)
Fix postdata stuff
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5245 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_httpd.cpp95
1 files changed, 40 insertions, 55 deletions
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp
index 276bc915f..e7b100b05 100644
--- a/src/modules/m_httpd.cpp
+++ b/src/modules/m_httpd.cpp
@@ -48,8 +48,8 @@ class HttpSocket : public InspSocket
std::string request_type;
std::string uri;
std::string http_version;
- int postsize;
- int amount;
+ unsigned int postsize;
+ unsigned int amount;
public:
@@ -221,7 +221,11 @@ class HttpSocket : public InspSocket
}
}
Instance->Log(DEBUG,"%d bytes to read for POST",postsize);
+ std::string::size_type x = headers.str().find("\r\n\r\n");
+ postdata = headers.str().substr(x+5, headers.str().length());
/* Get content length and store */
+ if (postdata.length() >= postsize)
+ ServeData();
}
else if (InternalState == HTTP_SERVE_RECV_POSTDATA)
{
@@ -230,73 +234,54 @@ class HttpSocket : public InspSocket
postdata.append(data);
if (amount >= postsize)
{
- InternalState = HTTP_SERVE_SEND_DATA;
-
- if ((http_version != "HTTP/1.1") && (http_version != "HTTP/1.0"))
- {
- SendHeaders(0, 505, "");
- }
- else
- {
- claimed = false;
- HTTPRequest httpr(request_type,uri,&headers,this,this->GetIP(),postdata);
- Event e((char*)&httpr, (Module*)HttpModule, "httpd_url");
- e.Send(this->Instance);
-
- if (!claimed)
- {
- SendHeaders(0, 404, "");
- Instance->Log(DEBUG,"Page not claimed, 404");
- }
-
- }
+ ServeData();
}
}
else
{
- /* Headers are complete */
- InternalState = HTTP_SERVE_SEND_DATA;
-
- if ((http_version != "HTTP/1.1") && (http_version != "HTTP/1.0"))
- {
- SendHeaders(0, 505, "");
- }
- else
- {
- if ((request_type == "GET") && (uri == "/"))
- {
- SendHeaders(index->ContentSize(), 200, "");
- this->Write(index->Contents());
- }
- else
- {
- claimed = false;
- HTTPRequest httpr(request_type,uri,&headers,this,this->GetIP(),postdata);
- Event e((char*)&httpr, (Module*)HttpModule, "httpd_url");
- e.Send(this->Instance);
-
- if (!claimed)
- {
- SendHeaders(0, 404, "");
- Instance->Log(DEBUG,"Page not claimed, 404");
- }
- }
- }
+ ServeData();
}
-
- return false;
+ return true;
}
return true;
}
else
{
- /* Bastard client closed the socket on us!
- * Oh wait, theyre SUPPOSED to do that!
- */
return false;
}
}
+ void ServeData()
+ {
+ /* Headers are complete */
+ InternalState = HTTP_SERVE_SEND_DATA;
+
+ if ((http_version != "HTTP/1.1") && (http_version != "HTTP/1.0"))
+ {
+ SendHeaders(0, 505, "");
+ }
+ else
+ {
+ if ((request_type == "GET") && (uri == "/"))
+ {
+ SendHeaders(index->ContentSize(), 200, "");
+ this->Write(index->Contents());
+ }
+ else
+ {
+ claimed = false;
+ HTTPRequest httpr(request_type,uri,&headers,this,this->GetIP(),postdata);
+ Event e((char*)&httpr, (Module*)HttpModule, "httpd_url");
+ e.Send(this->Instance);
+ if (!claimed)
+ {
+ SendHeaders(0, 404, "");
+ Instance->Log(DEBUG,"Page not claimed, 404");
+ }
+ }
+ }
+ }
+
void Page(std::stringstream* n, int response, std::string& extraheaders)
{
Instance->Log(DEBUG,"Sending page");