diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-09-14 11:15:39 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-09-14 11:15:39 +0000 |
commit | 663958cfd699855fede3704de5620e505a604d04 (patch) | |
tree | 09b4650d1ec4d7175c55e5386f6065f205e31907 /src/modules | |
parent | 30f7b57e98d0f726d9e2bb896589b0e07a9a87d5 (diff) |
Properly read POSTDATA
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5243 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_httpd.cpp | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index 8b7103adb..e12ca3f3d 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -49,6 +49,7 @@ class HttpSocket : public InspSocket std::string uri; std::string http_version; int postsize; + int amount; public: @@ -205,12 +206,48 @@ class HttpSocket : public InspSocket { /* Do we need to fetch postdata? */ postdata = ""; + amount = 0; InternalState = HTTP_SERVE_RECV_POSTDATA; - /* TODO: Get content length and store */ + std::string header_item; + while (headers >> header_item) + { + if (header_item == "Content-Length:") + { + headers >> header_item; + postsize = atoi(header_item.c_str()); + } + } + Instance->Log(DEBUG,"%d bytes to read for POST",postsize); + /* Get content length and store */ } else if (InternalState == HTTP_SERVE_RECV_POSTDATA) { /* Add postdata, once we have it all, send the event */ + amount += strlen(data); + 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"); + } + + } + } } else { |