summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2011-03-14 16:28:15 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2011-03-14 16:44:54 (GMT)
commitcdd52ad8acff0af2ecca1cef982228c6bb489feb (patch)
tree0ab4a7cafffe44591cc6e16e431ca0008f429dad /src/network
parent5f2eccbc8a392784868dd9919442642b4a9f9ef8 (diff)
downloadQt-cdd52ad8acff0af2ecca1cef982228c6bb489feb.zip
Qt-cdd52ad8acff0af2ecca1cef982228c6bb489feb.tar.gz
Qt-cdd52ad8acff0af2ecca1cef982228c6bb489feb.tar.bz2
QNAM HTTP: error() in case connection is closed unexpectedly
Task-number: QT-4658 Task-number: QT-3494 Reviewed-by: Peter Hartmann
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 82b5ce3..700b455 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -963,8 +963,20 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
} else {
errorCode = QNetworkReply::RemoteHostClosedError;
}
+ } else if (state == QHttpNetworkConnectionChannel::ReadingState) {
+ if (!reply->d_func()->expectContent()) {
+ // No content expected, this is a valid way to have the connection closed by the server
+ return;
+ }
+ if (reply->contentLength() == -1 && !reply->d_func()->isChunked()) {
+ // There was no content-length header and it's not chunked encoding,
+ // so this is a valid way to have the connection closed by the server
+ return;
+ }
+ // ok, we got a disconnect even though we did not expect it
+ errorCode = QNetworkReply::RemoteHostClosedError;
} else {
- return;
+ errorCode = QNetworkReply::RemoteHostClosedError;
}
break;
case QAbstractSocket::SocketTimeoutError:
@@ -992,6 +1004,7 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
if (reply) {
reply->d_func()->errorString = errorString;
emit reply->finishedWithError(errorCode, errorString);
+ reply = 0;
}
// send the next request
QMetaObject::invokeMethod(that, "_q_startNextRequest", Qt::QueuedConnection);