diff options
author | madmaxoft <github@xoft.cz> | 2013-09-27 20:33:18 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-09-27 20:33:18 +0200 |
commit | 0c3fd5e77d681c25757efaab6acb305d0b5630c1 (patch) | |
tree | 9d7b16cf1e27cce180c39c89353ad8855ef5def1 /source/HTTPServer/HTTPMessage.cpp | |
parent | Split cHTTPConnection implementation into a separate file. (diff) | |
download | cuberite-0c3fd5e77d681c25757efaab6acb305d0b5630c1.tar cuberite-0c3fd5e77d681c25757efaab6acb305d0b5630c1.tar.gz cuberite-0c3fd5e77d681c25757efaab6acb305d0b5630c1.tar.bz2 cuberite-0c3fd5e77d681c25757efaab6acb305d0b5630c1.tar.lz cuberite-0c3fd5e77d681c25757efaab6acb305d0b5630c1.tar.xz cuberite-0c3fd5e77d681c25757efaab6acb305d0b5630c1.tar.zst cuberite-0c3fd5e77d681c25757efaab6acb305d0b5630c1.zip |
Diffstat (limited to 'source/HTTPServer/HTTPMessage.cpp')
-rw-r--r-- | source/HTTPServer/HTTPMessage.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/source/HTTPServer/HTTPMessage.cpp b/source/HTTPServer/HTTPMessage.cpp index b784cb941..b2e21c712 100644 --- a/source/HTTPServer/HTTPMessage.cpp +++ b/source/HTTPServer/HTTPMessage.cpp @@ -88,7 +88,11 @@ bool cHTTPRequest::ParseHeaders(const char * a_IncomingData, size_t a_IdxEnd) End -= Next; } - return HasReceivedContentLength(); + if (!HasReceivedContentLength()) + { + SetContentLength(0); + } + return true; } @@ -125,12 +129,12 @@ size_t cHTTPRequest::ParseRequestLine(const char * a_Data, size_t a_IdxEnd) { case 0: { - m_Method.assign(a_Data, Last, i - Last - 1); + m_Method.assign(a_Data, Last, i - Last); break; } case 1: { - m_URL.assign(a_Data, Last, i - Last - 1); + m_URL.assign(a_Data, Last, i - Last); break; } default: @@ -145,7 +149,7 @@ size_t cHTTPRequest::ParseRequestLine(const char * a_Data, size_t a_IdxEnd) } case '\n': { - if ((i == 0) || (a_Data[i] != '\r') || (NumSpaces != 2) || (i < Last + 7)) + if ((i == 0) || (a_Data[i - 1] != '\r') || (NumSpaces != 2) || (i < Last + 7)) { // LF too early, without a CR, without two preceeding spaces or too soon after the second space return AString::npos; @@ -155,7 +159,7 @@ size_t cHTTPRequest::ParseRequestLine(const char * a_Data, size_t a_IdxEnd) { return AString::npos; } - return i; + return i + 1; } } // switch (a_Data[i]) } // for i - a_Data[] @@ -263,7 +267,7 @@ cHTTPResponse::cHTTPResponse(void) : void cHTTPResponse::AppendToData(AString & a_DataStream) const { - a_DataStream.append("200 OK\r\nTransfer-Encoding: chunked\r\nContent-Type: "); + a_DataStream.append("HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nContent-Type: "); a_DataStream.append(m_ContentType); a_DataStream.append("\r\n"); for (cNameValueMap::const_iterator itr = m_Headers.begin(), end = m_Headers.end(); itr != end; ++itr) |