diff options
author | Mattes D <github@xoft.cz> | 2016-02-20 11:50:52 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2016-03-01 16:19:58 +0100 |
commit | 52d18b4559cbaca949f722aa6901a6eb5f505f02 (patch) | |
tree | 614a441217b9ebcef17eb62e042223da1413b4aa /src/HTTP/HTTPMessage.cpp | |
parent | HTTP: Fixed response parser, unified API. (diff) | |
download | cuberite-52d18b4559cbaca949f722aa6901a6eb5f505f02.tar cuberite-52d18b4559cbaca949f722aa6901a6eb5f505f02.tar.gz cuberite-52d18b4559cbaca949f722aa6901a6eb5f505f02.tar.bz2 cuberite-52d18b4559cbaca949f722aa6901a6eb5f505f02.tar.lz cuberite-52d18b4559cbaca949f722aa6901a6eb5f505f02.tar.xz cuberite-52d18b4559cbaca949f722aa6901a6eb5f505f02.tar.zst cuberite-52d18b4559cbaca949f722aa6901a6eb5f505f02.zip |
Diffstat (limited to 'src/HTTP/HTTPMessage.cpp')
-rw-r--r-- | src/HTTP/HTTPMessage.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/HTTP/HTTPMessage.cpp b/src/HTTP/HTTPMessage.cpp index ca63397dd..5a7b86315 100644 --- a/src/HTTP/HTTPMessage.cpp +++ b/src/HTTP/HTTPMessage.cpp @@ -100,3 +100,60 @@ void cHTTPResponse::AppendToData(AString & a_DataStream) const + +//////////////////////////////////////////////////////////////////////////////// +// cHTTPIncomingRequest: + +cHTTPIncomingRequest::cHTTPIncomingRequest(const AString & a_Method, const AString & a_URL): + Super(mkRequest), + m_Method(a_Method), + m_URL(a_URL) +{ +} + + + + + +AString cHTTPIncomingRequest::GetURLPath(void) const +{ + auto idxQuestionMark = m_URL.find('?'); + if (idxQuestionMark == AString::npos) + { + return m_URL; + } + else + { + return m_URL.substr(0, idxQuestionMark); + } +} + + + + + +void cHTTPIncomingRequest::AddHeader(const AString & a_Key, const AString & a_Value) +{ + if ( + (NoCaseCompare(a_Key, "Authorization") == 0) && + (strncmp(a_Value.c_str(), "Basic ", 6) == 0) + ) + { + AString UserPass = Base64Decode(a_Value.substr(6)); + size_t idxCol = UserPass.find(':'); + if (idxCol != AString::npos) + { + m_AuthUsername = UserPass.substr(0, idxCol); + m_AuthPassword = UserPass.substr(idxCol + 1); + m_HasAuth = true; + } + } + if ((a_Key == "Connection") && (NoCaseCompare(a_Value, "keep-alive") == 0)) + { + m_AllowKeepAlive = true; + } +} + + + + |