diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2011-03-14 16:28:15 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2011-03-15 14:22:28 (GMT) |
commit | e0b7d5afff1a5087211883a80ab0d4c1292d12f3 (patch) | |
tree | 3992f18227d0017282e3454feb88c8f481a55a7d /src/network | |
parent | 5e47ee6a97f54f1cdac577f76cd338b40e624f32 (diff) | |
download | Qt-e0b7d5afff1a5087211883a80ab0d4c1292d12f3.zip Qt-e0b7d5afff1a5087211883a80ab0d4c1292d12f3.tar.gz Qt-e0b7d5afff1a5087211883a80ab0d4c1292d12f3.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.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 23dd518..6a05fd3 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -1020,8 +1020,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: @@ -1052,6 +1064,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); |