diff options
Diffstat (limited to 'src/network/access/qhttpnetworkconnectionchannel.cpp')
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 8980ed7a41..b4eda3477e 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -205,6 +205,26 @@ void QHttpNetworkConnectionChannel::close() } +void QHttpNetworkConnectionChannel::abort() +{ + if (!socket) + state = QHttpNetworkConnectionChannel::IdleState; + else if (socket->state() == QAbstractSocket::UnconnectedState) + state = QHttpNetworkConnectionChannel::IdleState; + else + state = QHttpNetworkConnectionChannel::ClosingState; + + // pendingEncrypt must only be true in between connected and encrypted states + pendingEncrypt = false; + + if (socket) { + // socket can be 0 since the host lookup is done from qhttpnetworkconnection.cpp while + // there is no socket yet. + socket->abort(); + } +} + + bool QHttpNetworkConnectionChannel::sendRequest() { Q_ASSERT(!protocolHandler.isNull()); @@ -252,7 +272,12 @@ bool QHttpNetworkConnectionChannel::ensureConnection() QAbstractSocket::SocketState socketState = socket->state(); // resend this request after we receive the disconnected signal - if (socketState == QAbstractSocket::ClosingState) { + // If !socket->isOpen() then we have already called close() on the socket, but there was still a + // pending connectToHost() for which we hadn't seen a connected() signal, yet. The connected() + // has now arrived (as indicated by socketState != ClosingState), but we cannot send anything on + // such a socket anymore. + if (socketState == QAbstractSocket::ClosingState || + (socketState != QAbstractSocket::UnconnectedState && !socket->isOpen())) { if (reply) resendCurrent = true; return false; @@ -1080,6 +1105,8 @@ void QHttpNetworkConnectionChannel::_q_sslErrors(const QList<QSslError> &errors) connection->d_func()->pauseConnection(); if (pendingEncrypt && !reply) connection->d_func()->dequeueRequest(socket); + if (reply) // a reply was actually dequeued. + reply->d_func()->connectionChannel = this; // set correct channel like in sendRequest() and queueRequest(); if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP) { if (reply) emit reply->sslErrors(errors); |