mirror of
https://github.com/inspircd/inspircd.git
synced 2025-04-21 15:31:27 -04:00
Fix postdata stuff
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5245 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
a19512aff3
commit
0f66106f8c
@ -48,8 +48,8 @@ class HttpSocket : public InspSocket
|
|||||||
std::string request_type;
|
std::string request_type;
|
||||||
std::string uri;
|
std::string uri;
|
||||||
std::string http_version;
|
std::string http_version;
|
||||||
int postsize;
|
unsigned int postsize;
|
||||||
int amount;
|
unsigned int amount;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -221,7 +221,11 @@ class HttpSocket : public InspSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Instance->Log(DEBUG,"%d bytes to read for POST",postsize);
|
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 */
|
/* Get content length and store */
|
||||||
|
if (postdata.length() >= postsize)
|
||||||
|
ServeData();
|
||||||
}
|
}
|
||||||
else if (InternalState == HTTP_SERVE_RECV_POSTDATA)
|
else if (InternalState == HTTP_SERVE_RECV_POSTDATA)
|
||||||
{
|
{
|
||||||
@ -230,73 +234,54 @@ class HttpSocket : public InspSocket
|
|||||||
postdata.append(data);
|
postdata.append(data);
|
||||||
if (amount >= postsize)
|
if (amount >= postsize)
|
||||||
{
|
{
|
||||||
InternalState = HTTP_SERVE_SEND_DATA;
|
ServeData();
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Headers are complete */
|
ServeData();
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Bastard client closed the socket on us!
|
|
||||||
* Oh wait, theyre SUPPOSED to do that!
|
|
||||||
*/
|
|
||||||
return false;
|
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)
|
void Page(std::stringstream* n, int response, std::string& extraheaders)
|
||||||
{
|
{
|
||||||
Instance->Log(DEBUG,"Sending page");
|
Instance->Log(DEBUG,"Sending page");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user