summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMårten Nordheim <[email protected]>2025-07-17 13:20:53 +0200
committerMårten Nordheim <[email protected]>2025-10-15 20:08:14 +0200
commitc21a3afb49760016ffc822b6ee795f378ff42c66 (patch)
treee1065a1a0042eee37d9755097b2163ea05addb0b
parent6689a8750ef94e6d1014965aae11adcbf3860b5f (diff)
HTTP: Adjust tests to handle or ignore header case
Task-number: QTBUG-137203 Pick-to: 6.10 6.8 Change-Id: I20ef2a336a8daa8be025c41f7949895d4a5143ea Reviewed-by: Axel Spoerl <[email protected]>
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp16
-rw-r--r--tests/auto/network/access/qnetworkreply_local/minihttpserver.h2
-rw-r--r--tests/auto/network/access/qnetworkreply_local/tst_qnetworkreply_local.cpp2
3 files changed, 12 insertions, 8 deletions
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index fa1d70a942b..fdc2dde7921 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -781,7 +781,7 @@ private:
void parseContentLength()
{
- int index = receivedData.indexOf("content-length:");
+ int index = receivedData.toLower().indexOf("content-length:");
if (index == -1)
return;
@@ -3620,7 +3620,7 @@ void tst_QNetworkReply::connectToIPv6Address()
QByteArray content = reply->readAll();
//qDebug() << server.receivedData;
QByteArray hostinfo = "\r\nhost: " + hostfield + ':' + QByteArray::number(server.serverPort()) + "\r\n";
- QVERIFY(server.receivedData.contains(hostinfo));
+ QVERIFY(server.receivedData.toLower().contains(hostinfo));
QCOMPARE(content, dataToSend);
QCOMPARE(reply->url(), request.url());
QCOMPARE(reply->error(), error);
@@ -8793,7 +8793,11 @@ void tst_QNetworkReply::httpUserAgent()
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
- QVERIFY(server.receivedData.contains("\r\nuser-agent: abcDEFghi\r\n"));
+ const char userAgentSearch[] = "\r\nuser-agent: ";
+ qsizetype userAgentIndex = server.receivedData.toLower().indexOf(userAgentSearch);
+ QCOMPARE_NE(userAgentIndex, -1);
+ userAgentIndex += sizeof(userAgentSearch) - 1;
+ QVERIFY(server.receivedData.slice(userAgentIndex).startsWith("abcDEFghi\r\n"));
}
void tst_QNetworkReply::synchronousAuthenticationCache()
@@ -8813,7 +8817,7 @@ void tst_QNetworkReply::synchronousAuthenticationCache()
"content-type: text/plain\r\n"
"\r\n"
"auth";
- QRegularExpression rx("authorization: Basic ([^\r\n]*)\r\n");
+ QRegularExpression rx("[Aa]uthorization: Basic ([^\r\n]*)\r\n");
QRegularExpressionMatch match = rx.match(receivedData);
if (match.hasMatch()) {
if (QByteArray::fromBase64(match.captured(1).toLatin1()) == "login:password") {
@@ -9526,7 +9530,7 @@ void tst_QNetworkReply::ioHttpCookiesDuringRedirect()
manager.setRedirectPolicy(oldRedirectPolicy);
QVERIFY(waitForFinish(reply) == Success);
- QVERIFY(target.receivedData.contains("\r\ncookie: hello=world\r\n"));
+ QVERIFY(target.receivedData.toLower().contains("\r\ncookie: hello=world\r\n"));
QVERIFY(validateRedirectedResponseHeaders(reply));
}
@@ -10439,7 +10443,7 @@ void tst_QNetworkReply::contentEncoding()
{
// Check that we included the content encoding method in our Accept-Encoding header
const QByteArray &receivedData = server.receivedData;
- int start = receivedData.indexOf("accept-encoding");
+ int start = receivedData.toLower().indexOf("accept-encoding");
QVERIFY(start != -1);
int end = receivedData.indexOf("\r\n", start);
QVERIFY(end != -1);
diff --git a/tests/auto/network/access/qnetworkreply_local/minihttpserver.h b/tests/auto/network/access/qnetworkreply_local/minihttpserver.h
index daad88cdbcc..ae1069d7a7d 100644
--- a/tests/auto/network/access/qnetworkreply_local/minihttpserver.h
+++ b/tests/auto/network/access/qnetworkreply_local/minihttpserver.h
@@ -152,7 +152,7 @@ private:
void parseContentLength(State &st, QByteArrayView header)
{
- qsizetype index = header.indexOf("\r\ncontent-length:");
+ qsizetype index = header.toByteArray().toLower().indexOf("\r\ncontent-length:");
if (index == -1)
return;
st.foundContentLength = true;
diff --git a/tests/auto/network/access/qnetworkreply_local/tst_qnetworkreply_local.cpp b/tests/auto/network/access/qnetworkreply_local/tst_qnetworkreply_local.cpp
index 8bed904c230..977a047c58e 100644
--- a/tests/auto/network/access/qnetworkreply_local/tst_qnetworkreply_local.cpp
+++ b/tests/auto/network/access/qnetworkreply_local/tst_qnetworkreply_local.cpp
@@ -270,7 +270,7 @@ void tst_QNetworkReply_local::fullServerName()
QVERIFY(receivedData.startsWith(expectedGet));
const QByteArray expectedHost = "host: " % url.host().toUtf8() % "\r\n";
- QVERIFY(receivedData.contains(expectedHost));
+ QVERIFY(receivedData.toLower().contains(expectedHost));
}
#endif