backport changes from 1.4.3 branch

This commit is contained in:
Marian Krivos
2012-01-07 11:06:14 +00:00
parent cc90b38ae5
commit 6268aa3865
69 changed files with 10381 additions and 5761 deletions

View File

@@ -69,29 +69,20 @@ HTTPBasicCredentials::HTTPBasicCredentials(const std::string& username, const st
HTTPBasicCredentials::HTTPBasicCredentials(const HTTPRequest& request)
{
static const int eof = std::char_traits<char>::eof();
std::string scheme;
std::string authInfo;
request.getCredentials(scheme, authInfo);
if (icompare(scheme, SCHEME) == 0)
{
parseAuthInfo(authInfo);
}
else throw NotAuthenticatedException("Basic authentication expected");
}
std::string scheme;
std::string info;
request.getCredentials(scheme, info);
if (icompare(scheme, SCHEME) == 0)
{
std::istringstream istr(info);
Base64Decoder decoder(istr);
int ch = decoder.get();
while (ch != eof && ch != ':')
{
_username += (char) ch;
ch = decoder.get();
}
if (ch == ':') ch = decoder.get();
while (ch != eof)
{
_password += (char) ch;
ch = decoder.get();
}
}
else throw NotAuthenticatedException("Basic authentication expected");
HTTPBasicCredentials::HTTPBasicCredentials(const std::string& authInfo)
{
parseAuthInfo(authInfo);
}
@@ -123,4 +114,25 @@ void HTTPBasicCredentials::authenticate(HTTPRequest& request)
}
void HTTPBasicCredentials::parseAuthInfo(const std::string& authInfo)
{
static const int eof = std::char_traits<char>::eof();
std::istringstream istr(authInfo);
Base64Decoder decoder(istr);
int ch = decoder.get();
while (ch != eof && ch != ':')
{
_username += (char) ch;
ch = decoder.get();
}
if (ch == ':') ch = decoder.get();
while (ch != eof)
{
_password += (char) ch;
ch = decoder.get();
}
}
} } // namespace Poco::Net