From b5d9dbf28b78aa17bfb70aa2e5fd3da99fe53ff0 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 27 Oct 2010 14:06:28 +0200 Subject: QNAM HTTP: Remove the error() of QHttpNetworkConnection Removed the distinction between reply error and connection error. The QNetworkAccessManager was treating them the same way anyway. Reviewed-by: Prasanth Task-Number: QTBUG-13234 --- src/network/access/qhttpnetworkconnection.cpp | 3 +-- src/network/access/qhttpnetworkconnection_p.h | 3 --- .../access/qhttpnetworkconnectionchannel.cpp | 24 ++++++++-------------- src/network/access/qnetworkaccesshttpbackend.cpp | 7 ------- src/network/access/qnetworkaccesshttpbackend_p.h | 1 - .../tst_qhttpnetworkconnection.cpp | 2 -- 6 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 3acaaff..92f8af7 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -377,8 +377,7 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket ? QNetworkReply::ProxyAuthenticationRequiredError : QNetworkReply::AuthenticationRequiredError; reply->d_func()->errorString = errorDetail(errorCode, socket); - emit q->error(errorCode, reply->d_func()->errorString); - emit channels[i].reply->finished(); + emit reply->finishedWithError(errorCode, reply->d_func()->errorString); // ### at this point the reply could be deleted socket->close(); return true; diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index 5d5caa6..8461426c 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -116,9 +116,6 @@ public: void ignoreSslErrors(const QList &errors, int channel = -1); #endif -Q_SIGNALS: - void error(QNetworkReply::NetworkError errorCode, const QString &detail = QString()); - private: Q_DECLARE_PRIVATE(QHttpNetworkConnection) Q_DISABLE_COPY(QHttpNetworkConnection) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 52a8e72..4e5de53 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -797,8 +797,7 @@ void QHttpNetworkConnectionChannel::handleStatus() ? QNetworkReply::ProxyAuthenticationRequiredError : QNetworkReply::AuthenticationRequiredError; reply->d_func()->errorString = connection->d_func()->errorDetail(errorCode, socket); - emit connection->error(errorCode, reply->d_func()->errorString); - emit reply->finished(); + emit reply->finishedWithError(errorCode, reply->d_func()->errorString); } break; default: @@ -945,7 +944,6 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket { if (!socket) return; - bool send2Reply = false; QNetworkReply::NetworkError errorCode = QNetworkReply::UnknownNetworkError; switch (socketError) { @@ -963,7 +961,6 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket closeAndResendCurrentRequest(); return; } else { - send2Reply = true; errorCode = QNetworkReply::RemoteHostClosedError; } } else { @@ -976,7 +973,6 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket closeAndResendCurrentRequest(); return; } - send2Reply = true; errorCode = QNetworkReply::TimeoutError; break; case QAbstractSocket::ProxyAuthenticationRequiredError: @@ -992,18 +988,14 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket } QPointer that = connection; QString errorString = connection->d_func()->errorDetail(errorCode, socket, socket->errorString()); - if (send2Reply) { - if (reply) { - reply->d_func()->errorString = errorString; - // this error matters only to this reply - emit reply->finishedWithError(errorCode, errorString); - } - // send the next request - QMetaObject::invokeMethod(that, "_q_startNextRequest", Qt::QueuedConnection); - } else { - // the failure affects all requests. - emit connection->error(errorCode, errorString); + + if (reply) { + reply->d_func()->errorString = errorString; + emit reply->finishedWithError(errorCode, errorString); } + // send the next request + QMetaObject::invokeMethod(that, "_q_startNextRequest", Qt::QueuedConnection); + if (that) //signal emission triggered event loop close(); } diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index ec10d34..2a0daf8 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -338,12 +338,6 @@ void QNetworkAccessHttpBackend::finished() QNetworkAccessBackend::finished(); } -void QNetworkAccessHttpBackend::setupConnection() -{ - connect(http, SIGNAL(error(QNetworkReply::NetworkError,QString)), - SLOT(httpError(QNetworkReply::NetworkError,QString))); -} - /* For a given httpRequest 1) If AlwaysNetwork, return @@ -672,7 +666,6 @@ void QNetworkAccessHttpBackend::open() cache->addEntry(cacheKey, http); } - setupConnection(); postRequest(); } diff --git a/src/network/access/qnetworkaccesshttpbackend_p.h b/src/network/access/qnetworkaccesshttpbackend_p.h index c4c88ae..568b2ee 100644 --- a/src/network/access/qnetworkaccesshttpbackend_p.h +++ b/src/network/access/qnetworkaccesshttpbackend_p.h @@ -125,7 +125,6 @@ private: quint64 resumeOffset; void disconnectFromHttp(); - void setupConnection(); void validateCache(QHttpNetworkRequest &httpRequest, bool &loadedFromCache); void invalidateCache(); void postRequest(); diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 29fe2fb..4a32a5a 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -330,8 +330,6 @@ void tst_QHttpNetworkConnection::put() connect(reply, SIGNAL(finished()), SLOT(finishedReply())); connect(reply, SIGNAL(finishedWithError(QNetworkReply::NetworkError, const QString &)), SLOT(finishedWithError(QNetworkReply::NetworkError, const QString &))); - connect(&connection, SIGNAL(error(QNetworkReply::NetworkError, const QString &)), - SLOT(finishedWithError(QNetworkReply::NetworkError, const QString &))); QTime stopWatch; stopWatch.start(); -- cgit v0.12