Do not keep the headers and message body in case of temporary redirect
The implementation of GET requests with body (QTBUG-112871) keeps the body after it has been redirected. However, in case of temporary redirect (status code 307) this seems to be an incorrect behavior. Reset the headers and the body in case of temporary redirect. Pick-to: 6.8 Change-Id: I10be702b017a42cca27a37dfe2249da2f59c0328 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit f6a5c7e011d24db22afa5a3bf92749b9bb9e9354) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e7562a50b9
commit
5581c62922
@ -796,7 +796,7 @@ QNetworkReply *QNetworkAccessManager::get(const QNetworkRequest &request)
|
||||
\note A GET request with a message body is not cached.
|
||||
|
||||
\note If the request is redirected, the message body will be kept only if the status code is
|
||||
307 or 308.
|
||||
308.
|
||||
*/
|
||||
|
||||
QNetworkReply *QNetworkAccessManager::get(const QNetworkRequest &request, QIODevice *data)
|
||||
@ -814,7 +814,7 @@ QNetworkReply *QNetworkAccessManager::get(const QNetworkRequest &request, QIODev
|
||||
\note A GET request with a message body is not cached.
|
||||
|
||||
\note If the request is redirected, the message body will be kept only if the status code is
|
||||
307 or 308.
|
||||
308.
|
||||
*/
|
||||
|
||||
QNetworkReply *QNetworkAccessManager::get(const QNetworkRequest &request, const QByteArray &data)
|
||||
|
@ -1260,10 +1260,10 @@ void QNetworkReplyHttpImplPrivate::onRedirected(const QUrl &redirectUrl, int htt
|
||||
return;
|
||||
}
|
||||
|
||||
// If the original operation was a GET with a body and the status code is either
|
||||
// 307 or 308 then keep the message body
|
||||
// If the original operation was a GET with a body and the status code is
|
||||
// 308 then keep the message body
|
||||
const bool getOperationKeepsBody = (operation == QNetworkAccessManager::GetOperation)
|
||||
&& (httpStatus == 307 || httpStatus == 308);
|
||||
&& httpStatus == 308;
|
||||
|
||||
redirectRequest = createRedirectRequest(originalRequest, url, maxRedirectsRemaining);
|
||||
operation = getRedirectOperation(operation, httpStatus);
|
||||
|
@ -2310,7 +2310,7 @@ void tst_QNetworkReply::getWithBodyRedirected()
|
||||
QVERIFY(validateRedirectedResponseHeaders(reply));
|
||||
|
||||
// Verify that the message body has arrived to the server
|
||||
if (status > 302) {
|
||||
if (status > 307) {
|
||||
QVERIFY(server2.contentLength != 0);
|
||||
QCOMPARE(server2.contentLength, dataFromClientToServer.size());
|
||||
QCOMPARE(server2.receivedData.right(dataFromClientToServer.size()), dataFromClientToServer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user