From 3b809f52adcdfc041d9fb1e6eb813af4ee082122 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 14 Sep 2006 11:42:03 +0000 Subject: Send error 400 when content-size is 0 or omitted for POST git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5246 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_httpd.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index e7b100b05..8c4bedbd1 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -220,12 +220,19 @@ class HttpSocket : public InspSocket postsize = atoi(header_item.c_str()); } } - 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(); + if (!postsize) + { + SendHeaders(0, 400, ""); + } + else + { + 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) { @@ -233,9 +240,7 @@ class HttpSocket : public InspSocket amount += strlen(data); postdata.append(data); if (amount >= postsize) - { ServeData(); - } } else { -- cgit v1.2.3