diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-04-06 21:43:23 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-04-06 21:43:23 +0200 |
commit | 7da308a7e158542fba0b28d3ad0e865b9e60bfc4 (patch) | |
tree | 84e11eab9c0608e71acedae999bbc3fba9c95d2a /src/HTTPServer/HTTPMessage.cpp | |
parent | Add CanChangeDirtToGrass function to Block Handlers. (diff) | |
parent | Updated cWorld::CreateProjectile() documentation (diff) | |
download | cuberite-7da308a7e158542fba0b28d3ad0e865b9e60bfc4.tar cuberite-7da308a7e158542fba0b28d3ad0e865b9e60bfc4.tar.gz cuberite-7da308a7e158542fba0b28d3ad0e865b9e60bfc4.tar.bz2 cuberite-7da308a7e158542fba0b28d3ad0e865b9e60bfc4.tar.lz cuberite-7da308a7e158542fba0b28d3ad0e865b9e60bfc4.tar.xz cuberite-7da308a7e158542fba0b28d3ad0e865b9e60bfc4.tar.zst cuberite-7da308a7e158542fba0b28d3ad0e865b9e60bfc4.zip |
Diffstat (limited to 'src/HTTPServer/HTTPMessage.cpp')
-rw-r--r-- | src/HTTPServer/HTTPMessage.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/HTTPServer/HTTPMessage.cpp b/src/HTTPServer/HTTPMessage.cpp index 98627eb8e..4a3611050 100644 --- a/src/HTTPServer/HTTPMessage.cpp +++ b/src/HTTPServer/HTTPMessage.cpp @@ -25,7 +25,7 @@ cHTTPMessage::cHTTPMessage(eKind a_Kind) : m_Kind(a_Kind), - m_ContentLength(-1) + m_ContentLength(AString::npos) { } @@ -81,23 +81,23 @@ cHTTPRequest::cHTTPRequest(void) : -int cHTTPRequest::ParseHeaders(const char * a_Data, int a_Size) +size_t cHTTPRequest::ParseHeaders(const char * a_Data, size_t a_Size) { if (!m_IsValid) { - return -1; + return AString::npos; } if (m_Method.empty()) { // The first line hasn't been processed yet - int res = ParseRequestLine(a_Data, a_Size); - if ((res < 0) || (res == a_Size)) + size_t res = ParseRequestLine(a_Data, a_Size); + if ((res == AString::npos) || (res == a_Size)) { return res; } - int res2 = m_EnvelopeParser.Parse(a_Data + res, a_Size - res); - if (res2 < 0) + size_t res2 = m_EnvelopeParser.Parse(a_Data + res, a_Size - res); + if (res2 == AString::npos) { m_IsValid = false; return res2; @@ -107,8 +107,8 @@ int cHTTPRequest::ParseHeaders(const char * a_Data, int a_Size) if (m_EnvelopeParser.IsInHeaders()) { - int res = m_EnvelopeParser.Parse(a_Data, a_Size); - if (res < 0) + size_t res = m_EnvelopeParser.Parse(a_Data, a_Size); + if (res == AString::npos) { m_IsValid = false; } @@ -138,7 +138,7 @@ AString cHTTPRequest::GetBareURL(void) const -int cHTTPRequest::ParseRequestLine(const char * a_Data, int a_Size) +size_t cHTTPRequest::ParseRequestLine(const char * a_Data, size_t a_Size) { m_IncomingHeaderData.append(a_Data, a_Size); size_t IdxEnd = m_IncomingHeaderData.size(); @@ -158,7 +158,7 @@ int cHTTPRequest::ParseRequestLine(const char * a_Data, int a_Size) if (LineStart >= IdxEnd) { m_IsValid = false; - return -1; + return AString::npos; } int NumSpaces = 0; @@ -186,7 +186,7 @@ int cHTTPRequest::ParseRequestLine(const char * a_Data, int a_Size) { // Too many spaces in the request m_IsValid = false; - return -1; + return AString::npos; } } NumSpaces += 1; @@ -198,13 +198,13 @@ int cHTTPRequest::ParseRequestLine(const char * a_Data, int a_Size) { // LF too early, without a CR, without two preceeding spaces or too soon after the second space m_IsValid = false; - return -1; + return AString::npos; } // Check that there's HTTP/version at the end if (strncmp(a_Data + URLEnd + 1, "HTTP/1.", 7) != 0) { m_IsValid = false; - return -1; + return AString::npos; } m_Method = m_IncomingHeaderData.substr(LineStart, MethodEnd - LineStart); m_URL = m_IncomingHeaderData.substr(MethodEnd + 1, URLEnd - MethodEnd - 1); |