diff options
Diffstat (limited to 'src/network/access')
-rw-r--r-- | src/network/access/qhttpnetworkconnection.cpp | 71 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 6 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkreply_p.h | 3 | ||||
-rw-r--r-- | src/network/access/qhttpthreaddelegate.cpp | 4 | ||||
-rw-r--r-- | src/network/access/qhttpthreaddelegate_p.h | 2 |
5 files changed, 50 insertions, 36 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 0f1132e2a8..fc4eccc761 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -189,28 +189,35 @@ bool QHttpNetworkConnectionPrivate::shouldEmitChannelError(QAbstractSocket *sock int i = indexOf(socket); int otherSocket = (i == 0 ? 1 : 0); - if (networkLayerState == QHttpNetworkConnectionPrivate::InProgress) { - if (channels[otherSocket].isSocketBusy() && (channels[otherSocket].state != QHttpNetworkConnectionChannel::ClosingState)) { - // this was the first socket to fail. - channels[i].close(); - emitError = false; - } - else { - // Both connection attempts has failed. + if (channelCount == 1) { + if (networkLayerState == QHttpNetworkConnectionPrivate::InProgress) networkLayerState = QHttpNetworkConnectionPrivate::Unknown; - channels[i].close(); - emitError = true; - } + channels[0].close(); + emitError = true; } else { - if ((networkLayerState == QHttpNetworkConnectionPrivate::IPv4) && (channels[i].networkLayerPreference != QAbstractSocket::IPv4Protocol) - || (networkLayerState == QHttpNetworkConnectionPrivate::IPv6) && (channels[i].networkLayerPreference != QAbstractSocket::IPv6Protocol)) { - // First connection worked so this is the second one to complete and it failed. - channels[i].close(); - QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); - emitError = false; + if (networkLayerState == QHttpNetworkConnectionPrivate::InProgress) { + if (channels[otherSocket].isSocketBusy() && (channels[otherSocket].state != QHttpNetworkConnectionChannel::ClosingState)) { + // this was the first socket to fail. + channels[i].close(); + emitError = false; + } + else { + // Both connection attempts has failed. + networkLayerState = QHttpNetworkConnectionPrivate::Unknown; + channels[i].close(); + emitError = true; + } + } else { + if ((networkLayerState == QHttpNetworkConnectionPrivate::IPv4) && (channels[i].networkLayerPreference != QAbstractSocket::IPv4Protocol) + || (networkLayerState == QHttpNetworkConnectionPrivate::IPv6) && (channels[i].networkLayerPreference != QAbstractSocket::IPv6Protocol)) { + // First connection worked so this is the second one to complete and it failed. + channels[i].close(); + QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); + emitError = false; + } + if (networkLayerState == QHttpNetworkConnectionPrivate::Unknown) + qWarning() << "We got a connection error when networkLayerState is Unknown"; } - if (networkLayerState == QHttpNetworkConnectionPrivate::Unknown) - qWarning() << "We got a connection error when networkLayerState is Unknown"; } return emitError; } @@ -917,10 +924,6 @@ void QHttpNetworkConnectionPrivate::readMoreLater(QHttpNetworkReply *reply) // lookup as then the hostinfo will already be in the cache. void QHttpNetworkConnectionPrivate::startHostInfoLookup() { - // At this time all channels should be unconnected. - Q_ASSERT(!channels[0].isSocketBusy()); - Q_ASSERT(!channels[1].isSocketBusy()); - networkLayerState = InProgress; // check if we already now can descide if this is IPv4 or IPv6 @@ -989,17 +992,23 @@ void QHttpNetworkConnectionPrivate::_q_hostLookupFinished(QHostInfo info) // connection will then be disconnected. void QHttpNetworkConnectionPrivate::startNetworkLayerStateLookup() { - // At this time all channels should be unconnected. - Q_ASSERT(!channels[0].isSocketBusy()); - Q_ASSERT(!channels[1].isSocketBusy()); + if (channelCount > 1) { + // At this time all channels should be unconnected. + Q_ASSERT(!channels[0].isSocketBusy()); + Q_ASSERT(!channels[1].isSocketBusy()); - networkLayerState = InProgress; + networkLayerState = InProgress; - channels[0].networkLayerPreference = QAbstractSocket::IPv4Protocol; - channels[1].networkLayerPreference = QAbstractSocket::IPv6Protocol; + channels[0].networkLayerPreference = QAbstractSocket::IPv4Protocol; + channels[1].networkLayerPreference = QAbstractSocket::IPv6Protocol; - channels[0].ensureConnection(); // Possibly delay this one.. - channels[1].ensureConnection(); + channels[0].ensureConnection(); // Possibly delay this one.. + channels[1].ensureConnection(); + } else { + networkLayerState = InProgress; + channels[0].networkLayerPreference = QAbstractSocket::AnyIPProtocol; + channels[0].ensureConnection(); + } } diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 8be876dd48..b1630c7b2b 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -955,6 +955,12 @@ void QHttpNetworkConnectionChannel::_q_connected() connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv4; else if (networkLayerPreference == QAbstractSocket::IPv6Protocol) connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv6; + else { + if (socket->peerAddress().protocol() == QAbstractSocket::IPv4Protocol) + connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv4; + else + connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv6; + } } else { if (((connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::IPv4) && (networkLayerPreference != QAbstractSocket::IPv4Protocol)) || ((connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::IPv6) && (networkLayerPreference != QAbstractSocket::IPv6Protocol))) { diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index 14219d484b..a6bf3fcc8e 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -147,8 +147,7 @@ Q_SIGNALS: void finished(); void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail = QString()); void headerChanged(); - // FIXME we need to change this to qint64! - void dataReadProgress(int done, int total); + void dataReadProgress(qint64 done, qint64 total); void dataSendProgress(qint64 done, qint64 total); void cacheCredentials(const QHttpNetworkRequest &request, QAuthenticator *authenticator); #ifndef QT_NO_NETWORKPROXY diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index 71227c822a..d7eeb1c619 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -310,7 +310,7 @@ void QHttpThreadDelegate::startRequest() this, SLOT(finishedWithErrorSlot(QNetworkReply::NetworkError,QString))); // some signals are only interesting when normal asynchronous style is used connect(httpReply,SIGNAL(readyRead()), this, SLOT(readyReadSlot())); - connect(httpReply,SIGNAL(dataReadProgress(int, int)), this, SLOT(dataReadProgressSlot(int,int))); + connect(httpReply,SIGNAL(dataReadProgress(qint64, qint64)), this, SLOT(dataReadProgressSlot(qint64,qint64))); connect(httpReply, SIGNAL(cacheCredentials(QHttpNetworkRequest,QAuthenticator*)), this, SLOT(cacheCredentialsSlot(QHttpNetworkRequest,QAuthenticator*))); #ifndef QT_NO_OPENSSL @@ -507,7 +507,7 @@ void QHttpThreadDelegate::synchronousHeaderChangedSlot() } -void QHttpThreadDelegate::dataReadProgressSlot(int done, int total) +void QHttpThreadDelegate::dataReadProgressSlot(qint64 done, qint64 total) { // If we don't have a download buffer don't attempt to go this codepath // It is not used by QNetworkAccessHttpBackend diff --git a/src/network/access/qhttpthreaddelegate_p.h b/src/network/access/qhttpthreaddelegate_p.h index c49cef242b..15c76b13fd 100644 --- a/src/network/access/qhttpthreaddelegate_p.h +++ b/src/network/access/qhttpthreaddelegate_p.h @@ -154,7 +154,7 @@ protected slots: void synchronousFinishedWithErrorSlot(QNetworkReply::NetworkError errorCode, const QString &detail = QString()); void headerChangedSlot(); void synchronousHeaderChangedSlot(); - void dataReadProgressSlot(int done, int total); + void dataReadProgressSlot(qint64 done, qint64 total); void cacheCredentialsSlot(const QHttpNetworkRequest &request, QAuthenticator *authenticator); #ifndef QT_NO_OPENSSL void sslErrorsSlot(const QList<QSslError> &errors); |