diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2024-01-25 12:39:08 +0100 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2024-01-25 18:37:48 +0100 |
commit | ffe0271a21e9574d1c9eab5fb9803573e17e0f22 (patch) | |
tree | 33f0af83f010e26b7723f93c0e70c6fc5b44719f /src/network/access/qhttp2protocolhandler.cpp | |
parent | 1e7f1e5b73b931931178bc884d3469439adf8c5c (diff) |
Http2: fix 401 authentication required w/o challenge
The code did not handle the path where we didn't have a challenge.
We cannot recover from that so we just have to fail the request.
Amends fe1b668861e8a3ef99e126821fcd3eeaa6044b54
Pick-to: 6.7 6.6 6.6.2 6.5 6.2
Fixes: QTBUG-121515
Change-Id: Ie39a92e7439785a09cad28e8f81599a51de5e27f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network/access/qhttp2protocolhandler.cpp')
-rw-r--r-- | src/network/access/qhttp2protocolhandler.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp index 4bb057b209..f69390e47a 100644 --- a/src/network/access/qhttp2protocolhandler.cpp +++ b/src/network/access/qhttp2protocolhandler.cpp @@ -1216,6 +1216,17 @@ void QHttp2ProtocolHandler::handleAuthorization(Stream &stream) // closed, so we don't need to call sendRequest ourselves. return true; } // else: Authentication failed or was cancelled + } else { + // No authentication header, but we got a 401/407 so we cannot + // succeed. We need to emit signals for headers and data, and then + // finishWithError. + emit httpReply->headerChanged(); + emit httpReply->readyRead(); + QNetworkReply::NetworkError error = httpReply->statusCode() == 401 + ? QNetworkReply::AuthenticationRequiredError + : QNetworkReply::ProxyAuthenticationRequiredError; + finishStreamWithError(stream, QNetworkReply::AuthenticationRequiredError, + m_connection->d_func()->errorDetail(error, m_socket)); } return false; }; |