summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp')
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 40e909113e..49abbede35 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -488,6 +488,7 @@ private Q_SLOTS:
void ioHttpRedirectPolicyErrors();
void ioHttpUserVerifiedRedirect_data();
void ioHttpUserVerifiedRedirect();
+ void ioHttpCookiesDuringRedirect();
#ifndef QT_NO_SSL
void putWithServerClosingConnectionImmediately();
#endif
@@ -8456,6 +8457,33 @@ void tst_QNetworkReply::ioHttpUserVerifiedRedirect()
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode);
}
+void tst_QNetworkReply::ioHttpCookiesDuringRedirect()
+{
+ MiniHttpServer target(httpEmpty200Response, false);
+
+ const QString cookieHeader = QStringLiteral("Set-Cookie: hello=world; Path=/;\r\n");
+ QString redirect = tempRedirectReplyStr();
+ // Insert 'cookieHeader' before the final \r\n
+ redirect.insert(redirect.length() - 2, cookieHeader);
+
+ QUrl url("http://localhost/");
+ url.setPort(target.serverPort());
+ redirect = redirect.arg(url.toString());
+ MiniHttpServer redirectServer(redirect.toLatin1(), false);
+
+ url = QUrl("http://localhost/");
+ url.setPort(redirectServer.serverPort());
+ QNetworkRequest request(url);
+ auto oldRedirectPolicy = manager.redirectPolicy();
+ manager.setRedirectPolicy(QNetworkRequest::RedirectPolicy::NoLessSafeRedirectPolicy);
+ QNetworkReplyPtr reply(manager.get(request));
+ // Set policy back to whatever it was
+ manager.setRedirectPolicy(oldRedirectPolicy);
+
+ QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY(target.receivedData.contains("\r\nCookie: hello=world\r\n"));
+}
+
#ifndef QT_NO_SSL
class PutWithServerClosingConnectionImmediatelyHandler: public QObject