From e21169796297f752a62db25c722ff8e2ff66d8dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 21 Jun 2019 09:29:22 +0200 Subject: QHttpNetworkConnectionChannel: don't close if we're already closing In some scenarios with QNAM we call socket->close, leading to a flush, leading to an error, leading to another error emission... To work around this scenario we stop trying to close the socket if the network channel is already closing. Change-Id: Id15504f476484ce61f11ba83a5755ceb5f581f9b Fixes: QTBUG-76567 Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnectionchannel.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/network/access') diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index d5f63af745..074c389689 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -207,6 +207,9 @@ void QHttpNetworkConnectionChannel::init() void QHttpNetworkConnectionChannel::close() { + if (state == QHttpNetworkConnectionChannel::ClosingState) + return; + if (!socket) state = QHttpNetworkConnectionChannel::IdleState; else if (socket->state() == QAbstractSocket::UnconnectedState) -- cgit v1.2.3 From 89655525ae56dd9662f1873efdce72cbff7bb932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 21 Jun 2019 09:20:39 +0200 Subject: QHttpNetworkConnection: Change assert to early return and handle Http2 When using a http proxy (and presumably other proxies) we might have failed/aborted (aka "finished") the request and _then_ receive a "proxy authentication required" message from the proxy. In this case there is no spdy/http2 reply in the queue, so asserting is wrong. Change-Id: Id9b76b580299f6a6cd6efad62d6aaf63183816fb Fixes: QTBUG-76426 Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnection.cpp | 12 +++++++----- src/network/access/qhttpnetworkconnectionchannel.cpp | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/network/access') diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index c58fd24a44..10c8541c5f 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -1528,19 +1528,21 @@ void QHttpNetworkConnectionPrivate::emitProxyAuthenticationRequired(const QHttpN // dialog is displaying pauseConnection(); QHttpNetworkReply *reply; -#ifndef QT_NO_SSL - if (connectionType == QHttpNetworkConnection::ConnectionTypeSPDY) { + if (connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2 + || connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2Direct +#if QT_CONFIG(ssl) + || connectionType == QHttpNetworkConnection::ConnectionTypeSPDY +#endif + ) { + // we choose the reply to emit the proxyAuth signal from somewhat arbitrarily, // but that does not matter because the signal will ultimately be emitted // by the QNetworkAccessManager. Q_ASSERT(chan->spdyRequestsToSend.count() > 0); reply = chan->spdyRequestsToSend.cbegin().value().second; } else { // HTTP -#endif // QT_NO_SSL reply = chan->reply; -#ifndef QT_NO_SSL } -#endif // QT_NO_SSL Q_ASSERT(reply); emit reply->proxyAuthenticationRequired(proxy, auth); diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 074c389689..38adca2633 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -1115,11 +1115,13 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket void QHttpNetworkConnectionChannel::_q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator* auth) { if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2 + || connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2Direct #ifndef QT_NO_SSL || connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY #endif ) { - connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth); + if (spdyRequestsToSend.count() > 0) + connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth); } else { // HTTP // Need to dequeue the request before we can emit the error. if (!reply) -- cgit v1.2.3