Fix error signal supression for failed DNS lookups

Sometimes the signal QNetworkReply::error(QNetworkReply::NetworkError)
is not emitted for certain requests.

This happens under the following conditions:

* The hostname provided in the request is incorrect, i.e it will
  result in a DNS lookup failure.
* There is a previous request, for the _same_ host, already pending.

The first request that comes for the (incorrect hostname) url, gets
enqueued via QHttpNetworkConnectionPrivate::queueRequest(). Here,
after starting a DNS lookup, we mark the network state of this
connection as - "InProgress".

Now, if a second reuest comes for the same host, we use the existing
HTTP connection object as it's present in the cache. However, when
enqueing the request (in queueRequest()), we see that the network is
NOT in "Unknown" state and return immediately without adding this new
request to the list of pending lookups (via QHostInfo::lookupHost()).

To fix this issue, we should queue incoming lookup requests, even if
the current (HTTP) connection is in the "InProgress" state, so that we
can inform the requestor of a failed lookup. Since
QHostInfo::lookupHost() handles lookups for duplicate hostnames
properly, things should be fine even if multiple requests for the same
host have been enqueued.

Task-number: QTBUG-32911
Change-Id: I6a9c8430121e9a5a2d45983b6bda70c324437992
Reviewed-by: Peter Hartmann <phartmann@blackberry.com>
This commit is contained in:
Mandeep Sandhu 2013-09-17 13:04:39 +05:30 committed by The Qt Project
parent 0f3315a4dd
commit f30641a7f8

View File

@ -560,7 +560,7 @@ QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetwor
// untill we have started the first connection attempt. So no
// request will be started untill we know if IPv4 or IPv6
// should be used.
if (networkLayerState == Unknown) {
if (networkLayerState == Unknown || networkLayerState == InProgress) {
startHostInfoLookup();
} else if ( networkLayerState == IPv4 || networkLayerState == IPv6 ) {
// this used to be called via invokeMethod and a QueuedConnection