summaryrefslogtreecommitdiffstats
path: root/source/HTTPServer/HTTPMessage.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-10-04 20:28:30 +0200
committermadmaxoft <github@xoft.cz>2013-10-04 20:28:30 +0200
commitdb3d83b38dd61b90466a0721fa9104e742f3fb8b (patch)
treeba45a5a87eb7a688cbbe05587abaf1bea667371f /source/HTTPServer/HTTPMessage.cpp
parentHTTP Server can now parse multipart/form-data forms; better architecture. (diff)
downloadcuberite-db3d83b38dd61b90466a0721fa9104e742f3fb8b.tar
cuberite-db3d83b38dd61b90466a0721fa9104e742f3fb8b.tar.gz
cuberite-db3d83b38dd61b90466a0721fa9104e742f3fb8b.tar.bz2
cuberite-db3d83b38dd61b90466a0721fa9104e742f3fb8b.tar.lz
cuberite-db3d83b38dd61b90466a0721fa9104e742f3fb8b.tar.xz
cuberite-db3d83b38dd61b90466a0721fa9104e742f3fb8b.tar.zst
cuberite-db3d83b38dd61b90466a0721fa9104e742f3fb8b.zip
Diffstat (limited to 'source/HTTPServer/HTTPMessage.cpp')
-rw-r--r--source/HTTPServer/HTTPMessage.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/source/HTTPServer/HTTPMessage.cpp b/source/HTTPServer/HTTPMessage.cpp
index ed5c87e84..6cf9464a3 100644
--- a/source/HTTPServer/HTTPMessage.cpp
+++ b/source/HTTPServer/HTTPMessage.cpp
@@ -71,7 +71,8 @@ cHTTPRequest::cHTTPRequest(void) :
super(mkRequest),
m_EnvelopeParser(*this),
m_IsValid(true),
- m_UserData(NULL)
+ m_UserData(NULL),
+ m_HasAuth(false)
{
}
@@ -204,6 +205,20 @@ int cHTTPRequest::ParseRequestLine(const char * a_Data, int a_Size)
void cHTTPRequest::OnHeaderLine(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;
+ }
+ }
AddHeader(a_Key, a_Value);
}