Http: don't try to send request on a closed socket

We have code in the protocolHandlers that tries to handle this case, but
if we have an error before we create protocolHandler (read: proxy
complains about something) we will assert in debug, or
deref nullptr in release.

Pick-to: 6.5 6.2
Change-Id: I4bde9c8af0fa96dc11f77ca4d4b5cb84c31b54fa
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 5c7c44cf8390cb08f3b46c9763c2d11da7179c93)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Mårten Nordheim 2023-10-10 15:45:14 +02:00 committed by Qt Cherry-pick Bot
parent 173038ae19
commit 5632626375

View File

@ -1043,6 +1043,11 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
//resend the necessary ones. //resend the necessary ones.
for (int i = 0; i < activeChannelCount; ++i) { for (int i = 0; i < activeChannelCount; ++i) {
if (channels[i].resendCurrent && (channels[i].state != QHttpNetworkConnectionChannel::ClosingState)) { if (channels[i].resendCurrent && (channels[i].state != QHttpNetworkConnectionChannel::ClosingState)) {
if (!channels[i].socket
|| channels[i].socket->state() == QAbstractSocket::UnconnectedState) {
if (!channels[i].ensureConnection())
continue;
}
channels[i].resendCurrent = false; channels[i].resendCurrent = false;
// if this is not possible, error will be emitted and connection terminated // if this is not possible, error will be emitted and connection terminated