QNetworkAccessManager: hostInfo lookup should use proxy if set

startHostInfoLookup will try to detect if IPv4 or IPv6 will be used
when connecting to the host. If a proxy is set we should lookup
the proxy hostname instead, in case host name can't be resolved
via DNS and should be resolved by the proxy.

Task-number: QTBUG-21889
Change-Id: I2012798784fc40f153469a1298e261c52981297e
Reviewed-on: http://codereview.qt-project.org/6447
Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
This commit is contained in:
Martin Petersson 2011-10-11 16:36:55 +02:00 committed by Qt by Nokia
parent f43ca8d4e7
commit 2b58e3db35

View File

@ -926,8 +926,16 @@ void QHttpNetworkConnectionPrivate::startHostInfoLookup()
networkLayerState = InProgress;
// check if we already now can descide if this is IPv4 or IPv6
QString lookupHost = hostName;
#ifndef QT_NO_NETWORKPROXY
if (networkProxy.capabilities() & QNetworkProxy::HostNameLookupCapability) {
lookupHost = networkProxy.hostName();
} else if (channels[0].socket->proxy().capabilities() & QNetworkProxy::HostNameLookupCapability) {
lookupHost = channels[0].socket->proxy().hostName();
}
#endif
QHostAddress temp;
if (temp.setAddress(hostName)) {
if (temp.setAddress(lookupHost)) {
if (temp.protocol() == QAbstractSocket::IPv4Protocol) {
networkLayerState = QHttpNetworkConnectionPrivate::IPv4;
QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
@ -940,7 +948,7 @@ void QHttpNetworkConnectionPrivate::startHostInfoLookup()
} else {
int hostLookupId;
bool immediateResultValid = false;
QHostInfo hostInfo = qt_qhostinfo_lookup(hostName,
QHostInfo hostInfo = qt_qhostinfo_lookup(lookupHost,
this->q_func(),
SLOT(_q_hostLookupFinished(QHostInfo)),
&immediateResultValid,