diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2009-11-09 13:49:14 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2009-11-09 14:42:08 (GMT) |
commit | 88b713cb11bdbded762c4004aae87aa9524d73cf (patch) | |
tree | 549f84973fa08acfe6ef23b8ed78e15cacc7ddcf /src/network/access | |
parent | 89421331366ac1d34ff18bcd40f3e78f7fa1883e (diff) | |
download | Qt-88b713cb11bdbded762c4004aae87aa9524d73cf.zip Qt-88b713cb11bdbded762c4004aae87aa9524d73cf.tar.gz Qt-88b713cb11bdbded762c4004aae87aa9524d73cf.tar.bz2 |
QNAM HTTP Code: Also send our locale name as accept-language
Inspired by merge request 2012 by Joel Nordell
Reviewed-by: Peter Hartmann
Diffstat (limited to 'src/network/access')
-rw-r--r-- | src/network/access/qhttpnetworkconnection.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 1124337..7d54908 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -194,11 +194,20 @@ void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair) // some websites mandate an accept-language header and fail // if it is not sent. This is a problem with the website and - // not with us, but we work around this by setting a - // universal one always. + // not with us, but we work around this by setting + // one always. value = request.headerField("accept-language"); - if (value.isEmpty()) - request.setHeaderField("accept-language", "en,*"); + if (value.isEmpty()) { + QString systemLocale = QLocale::system().name().replace(QChar::fromAscii('_'),QChar::fromAscii('-')); + QString acceptLanguage; + if (systemLocale == QLatin1String("C")) + acceptLanguage = QString::fromAscii("en,*"); + else if (systemLocale.startsWith(QLatin1String("en-"))) + acceptLanguage = QString::fromAscii("%1,*").arg(systemLocale); + else + acceptLanguage = QString::fromAscii("%1,en,*").arg(systemLocale); + request.setHeaderField("accept-language", acceptLanguage.toAscii()); + } // set the User Agent value = request.headerField("user-agent"); |