summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qauthenticator.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-07-14 11:23:56 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-07-15 09:50:42 (GMT)
commit367aa34cbcfa109926087e89d49f9223c1409d44 (patch)
tree51def324b6328a8d02b37c69fdaa7e2b2d466f04 /src/network/kernel/qauthenticator.cpp
parent73473634b706548d603dafe22c9424a007d1bf3b (diff)
downloadQt-367aa34cbcfa109926087e89d49f9223c1409d44.zip
Qt-367aa34cbcfa109926087e89d49f9223c1409d44.tar.gz
Qt-367aa34cbcfa109926087e89d49f9223c1409d44.tar.bz2
Add a QAuthenticatorPrivate parsing for the headers without QHttpResponseHeader
Reviewed-by: Markus Goetz
Diffstat (limited to 'src/network/kernel/qauthenticator.cpp')
-rw-r--r--src/network/kernel/qauthenticator.cpp39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp
index e7442c0..0ea4fd4 100644
--- a/src/network/kernel/qauthenticator.cpp
+++ b/src/network/kernel/qauthenticator.cpp
@@ -241,7 +241,20 @@ QAuthenticatorPrivate::QAuthenticatorPrivate()
#ifndef QT_NO_HTTP
void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, bool isProxy)
{
- QList<QPair<QString, QString> > values = header.values();
+ const QList<QPair<QString, QString> > values = header.values();
+ QList<QPair<QByteArray, QByteArray> > rawValues;
+
+ QList<QPair<QString, QString> >::const_iterator it, end;
+ for (it = values.constBegin(), end = values.constEnd(); it != end; ++it)
+ rawValues.append(qMakePair(it->first.toLatin1(), it->second.toUtf8()));
+
+ // continue in byte array form
+ parseHttpResponse(rawValues, isProxy);
+}
+#endif
+
+void QAuthenticatorPrivate::parseHttpResponse(const QList<QPair<QByteArray, QByteArray> > &values, bool isProxy)
+{
const char *search = isProxy ? "proxy-authenticate" : "www-authenticate";
method = None;
@@ -255,24 +268,25 @@ void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header,
authentication parameters.
*/
- QString headerVal;
+ QByteArray headerVal;
for (int i = 0; i < values.size(); ++i) {
- const QPair<QString, QString> &current = values.at(i);
- if (current.first.toLower() != QLatin1String(search))
+ const QPair<QByteArray, QByteArray> &current = values.at(i);
+ if (current.first.toLower() != search)
continue;
- QString str = current.second;
- if (method < Basic && str.startsWith(QLatin1String("Basic"), Qt::CaseInsensitive)) {
- method = Basic; headerVal = str.mid(6);
- } else if (method < Ntlm && str.startsWith(QLatin1String("NTLM"), Qt::CaseInsensitive)) {
+ QByteArray str = current.second.toLower();
+ if (method < Basic && str.startsWith("basic")) {
+ method = Basic;
+ headerVal = current.second.mid(6);
+ } else if (method < Ntlm && str.startsWith("ntlm")) {
method = Ntlm;
- headerVal = str.mid(5);
- } else if (method < DigestMd5 && str.startsWith(QLatin1String("Digest"), Qt::CaseInsensitive)) {
+ headerVal = current.second.mid(5);
+ } else if (method < DigestMd5 && str.startsWith("digest")) {
method = DigestMd5;
- headerVal = str.mid(7);
+ headerVal = current.second.mid(7);
}
}
- challenge = headerVal.trimmed().toLatin1();
+ challenge = headerVal.trimmed();
QHash<QByteArray, QByteArray> options = parseDigestAuthenticationChallenge(challenge);
switch(method) {
@@ -300,7 +314,6 @@ void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header,
phase = Invalid;
}
}
-#endif
QByteArray QAuthenticatorPrivate::calculateResponse(const QByteArray &requestMethod, const QByteArray &path)
{