src/network/access/qhttpnetworkconnection.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
child 7 f7bc934e204c
child 18 2f34d5167611
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   192 #endif
   192 #endif
   193     }
   193     }
   194 
   194 
   195     // some websites mandate an accept-language header and fail
   195     // some websites mandate an accept-language header and fail
   196     // if it is not sent. This is a problem with the website and
   196     // if it is not sent. This is a problem with the website and
   197     // not with us, but we work around this by setting a
   197     // not with us, but we work around this by setting
   198     // universal one always.
   198     // one always.
   199     value = request.headerField("accept-language");
   199     value = request.headerField("accept-language");
   200     if (value.isEmpty())
   200     if (value.isEmpty()) {
   201         request.setHeaderField("accept-language", "en,*");
   201         QString systemLocale = QLocale::system().name().replace(QChar::fromAscii('_'),QChar::fromAscii('-'));
       
   202         QString acceptLanguage;
       
   203         if (systemLocale == QLatin1String("C"))
       
   204             acceptLanguage = QString::fromAscii("en,*");
       
   205         else if (systemLocale.startsWith(QLatin1String("en-")))
       
   206             acceptLanguage = QString::fromAscii("%1,*").arg(systemLocale);
       
   207         else
       
   208             acceptLanguage = QString::fromAscii("%1,en,*").arg(systemLocale);
       
   209         request.setHeaderField("Accept-Language", acceptLanguage.toAscii());
       
   210     }
   202 
   211 
   203     // set the User Agent
   212     // set the User Agent
   204     value = request.headerField("user-agent");
   213     value = request.headerField("user-agent");
   205     if (value.isEmpty())
   214     if (value.isEmpty())
   206         request.setHeaderField("User-Agent", "Mozilla/5.0");
   215         request.setHeaderField("User-Agent", "Mozilla/5.0");
   370     if (channels[i].authMehtod != QAuthenticatorPrivate::None) {
   379     if (channels[i].authMehtod != QAuthenticatorPrivate::None) {
   371         if (!(channels[i].authMehtod == QAuthenticatorPrivate::Ntlm && channels[i].lastStatus != 401)) {
   380         if (!(channels[i].authMehtod == QAuthenticatorPrivate::Ntlm && channels[i].lastStatus != 401)) {
   372             QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].authenticator);
   381             QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].authenticator);
   373             if (priv && priv->method != QAuthenticatorPrivate::None) {
   382             if (priv && priv->method != QAuthenticatorPrivate::None) {
   374                 QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false));
   383                 QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false));
   375                 request.setHeaderField("authorization", response);
   384                 request.setHeaderField("Authorization", response);
   376             }
   385             }
   377         }
   386         }
   378     }
   387     }
   379     if (channels[i].proxyAuthMehtod != QAuthenticatorPrivate::None) {
   388     if (channels[i].proxyAuthMehtod != QAuthenticatorPrivate::None) {
   380         if (!(channels[i].proxyAuthMehtod == QAuthenticatorPrivate::Ntlm && channels[i].lastStatus != 407)) {
   389         if (!(channels[i].proxyAuthMehtod == QAuthenticatorPrivate::Ntlm && channels[i].lastStatus != 407)) {
   381             QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].proxyAuthenticator);
   390             QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].proxyAuthenticator);
   382             if (priv && priv->method != QAuthenticatorPrivate::None) {
   391             if (priv && priv->method != QAuthenticatorPrivate::None) {
   383                 QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false));
   392                 QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false));
   384                 request.setHeaderField("proxy-authorization", response);
   393                 request.setHeaderField("Proxy-Authorization", response);
   385             }
   394             }
   386         }
   395         }
   387     }
   396     }
   388 }
   397 }
   389 
   398