diff --git a/src/providers/wfs/qgsbasenetworkrequest.cpp b/src/providers/wfs/qgsbasenetworkrequest.cpp index 4395a92c5b34..31a5aa0c3c21 100644 --- a/src/providers/wfs/qgsbasenetworkrequest.cpp +++ b/src/providers/wfs/qgsbasenetworkrequest.cpp @@ -508,7 +508,7 @@ QStringList QgsBaseNetworkRequest::sendOPTIONS( const QUrl &url ) for ( const auto &headerKeyValue : mResponseHeaders ) { - if ( headerKeyValue.first == QByteArray( "Allow" ) ) + if ( headerKeyValue.first.compare( QByteArray( "Allow" ), Qt::CaseInsensitive ) == 0 ) { allowValue = headerKeyValue.second; break; diff --git a/tests/src/core/testqgsnetworkaccessmanager.cpp b/tests/src/core/testqgsnetworkaccessmanager.cpp index 678ce0eae25d..2a27b20221a6 100644 --- a/tests/src/core/testqgsnetworkaccessmanager.cpp +++ b/tests/src/core/testqgsnetworkaccessmanager.cpp @@ -419,7 +419,15 @@ void TestQgsNetworkAccessManager::fetchEncodedContent() connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent &reply ) { QCOMPARE( reply.error(), QNetworkReply::NoError ); QCOMPARE( reply.requestId(), requestId ); - QVERIFY( reply.rawHeaderList().contains( "Content-Length" ) ); + + // newer qt versions force headers to lower case, older ones didn't + QStringList lowerCaseRawHeaders; + for ( const QByteArray &header : reply.rawHeaderList() ) + { + lowerCaseRawHeaders.append( header.toLower() ); + } + + QVERIFY( lowerCaseRawHeaders.contains( "content-length" ) ); QCOMPARE( reply.request().url(), u ); loaded = true; } ); @@ -502,7 +510,15 @@ void TestQgsNetworkAccessManager::fetchPost() connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent &reply ) { QCOMPARE( reply.error(), QNetworkReply::NoError ); QCOMPARE( reply.requestId(), requestId ); - QVERIFY( reply.rawHeaderList().contains( "Content-Type" ) ); + + // newer qt versions force headers to lower case, older ones didn't + QStringList lowerCaseRawHeaders; + for ( const QByteArray &header : reply.rawHeaderList() ) + { + lowerCaseRawHeaders.append( header.toLower() ); + } + + QVERIFY( lowerCaseRawHeaders.contains( "content-type" ) ); QCOMPARE( reply.request().url(), u ); loaded = true; } ); @@ -591,7 +607,15 @@ void TestQgsNetworkAccessManager::fetchPostMultiPart() el.exec(); QCOMPARE( reply->error(), QNetworkReply::NoError ); - QVERIFY( reply->rawHeaderList().contains( "Content-Type" ) ); + + // newer qt versions force headers to lower case, older ones didn't + QStringList lowerCaseRawHeaders; + for ( const QByteArray &header : reply->rawHeaderList() ) + { + lowerCaseRawHeaders.append( header.toLower() ); + } + QVERIFY( lowerCaseRawHeaders.contains( "content-type" ) ); + QCOMPARE( reply->request().url(), u ); } diff --git a/tests/src/python/test_qgsblockingnetworkrequest.py b/tests/src/python/test_qgsblockingnetworkrequest.py index d1ae0981ac1d..d4f8294ddf87 100644 --- a/tests/src/python/test_qgsblockingnetworkrequest.py +++ b/tests/src/python/test_qgsblockingnetworkrequest.py @@ -110,9 +110,10 @@ def testGet(self): reply = request.reply() self.assertEqual(reply.error(), QNetworkReply.NetworkError.NoError) self.assertEqual(reply.content(), "\n") + # newer qt versions FORCE lowercase header keys, older ones didn't self.assertEqual( - reply.rawHeaderList(), - [b"Server", b"Date", b"Content-type", b"Content-Length"], + [h.data().decode().lower() for h in reply.rawHeaderList()], + ["server", "date", "content-type", "content-length"], ) self.assertEqual(reply.rawHeader(b"Content-type"), "text/html") self.assertEqual(reply.rawHeader(b"xxxxxxxxx"), "")