diff options
Diffstat (limited to 'tests/auto/network/access/qrestaccessmanager/tst_qrestaccessmanager.cpp')
-rw-r--r-- | tests/auto/network/access/qrestaccessmanager/tst_qrestaccessmanager.cpp | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/tests/auto/network/access/qrestaccessmanager/tst_qrestaccessmanager.cpp b/tests/auto/network/access/qrestaccessmanager/tst_qrestaccessmanager.cpp index 602bffd9c1..d6bdda76ca 100644 --- a/tests/auto/network/access/qrestaccessmanager/tst_qrestaccessmanager.cpp +++ b/tests/auto/network/access/qrestaccessmanager/tst_qrestaccessmanager.cpp @@ -3,7 +3,9 @@ #include "httptestserver_p.h" +#if QT_CONFIG(http) #include <QtNetwork/qhttpmultipart.h> +#endif #include <QtNetwork/qrestaccessmanager.h> #include <QtNetwork/qauthenticator.h> #include <QtNetwork/qnetworkreply.h> @@ -13,6 +15,7 @@ #include <QTest> #include <QtTest/qsignalspy.h> +#include <QtCore/private/qglobal_p.h> // for access to Qt's feature system #include <QtCore/qbuffer.h> #include <QtCore/qjsonobject.h> #include <QtCore/qjsondocument.h> @@ -32,7 +35,9 @@ private slots: void initialization(); void destruction(); void callbacks(); +#if QT_CONFIG(http) void requests(); +#endif void reply(); void errors(); void body(); @@ -89,6 +94,7 @@ void tst_QRestAccessManager::reply() networkReply = nullptr; \ } +#if QT_CONFIG(http) void tst_QRestAccessManager::requests() { // A basic test for each HTTP method against the local testserver. @@ -267,6 +273,7 @@ void tst_QRestAccessManager::requests() //manager.sendCustomRequest(request, this, [](){}); // No verb && no data //manager.sendCustomRequest(request, "FOOBAR", this, [](){}); // No verb || no data } +#endif void tst_QRestAccessManager::memberHandler(QRestReply &reply) { @@ -723,11 +730,29 @@ void tst_QRestAccessManager::text() // should consider the indicated charset and convert it to an UTF-16 QString => the returned // QString from text() should match with the original (UTF-16) QString. - // Successful UTF-8 + // Successful UTF-8 (explicit) serverSideResponse.headers.append(Header::ContentType, "text/plain; charset=UTF-8"_ba); serverSideResponse.body = encUTF8(sourceString); VERIFY_TEXT_REPLY_OK; + // Successful UTF-8 (obfuscated) + serverSideResponse.headers.removeAll(Header::ContentType); + serverSideResponse.headers.append(Header::ContentType, "text/plain; charset=\"UT\\F-8\""_ba); + serverSideResponse.body = encUTF8(sourceString); + VERIFY_TEXT_REPLY_OK; + + // Successful UTF-8 (empty charset) + serverSideResponse.headers.removeAll(Header::ContentType); + serverSideResponse.headers.append(Header::ContentType, "text/plain; charset=\"\""_ba); + serverSideResponse.body = encUTF8(sourceString); + VERIFY_TEXT_REPLY_OK; + + // Successful UTF-8 (implicit) + serverSideResponse.headers.removeAll(Header::ContentType); + serverSideResponse.headers.append(Header::ContentType, "text/plain"_ba); + serverSideResponse.body = encUTF8(sourceString); + VERIFY_TEXT_REPLY_OK; + // Successful UTF-16 serverSideResponse.headers.removeAll(Header::ContentType); serverSideResponse.headers.append(Header::ContentType, "text/plain; charset=UTF-16"_ba); @@ -746,10 +771,17 @@ void tst_QRestAccessManager::text() serverSideResponse.body = encUTF32(sourceString); VERIFY_TEXT_REPLY_OK; - // Successful UTF-32 with spec-wise allowed extra content in the Content-Type header value + // Successful UTF-32 with spec-wise allowed extra trailing content in the Content-Type header value + serverSideResponse.headers.removeAll(Header::ContentType); + serverSideResponse.headers.append(Header::ContentType, + "text(this is a \\)comment)/ (this (too)) plain; charset = \"UTF-32\";extraparameter=bar"_ba); + serverSideResponse.body = encUTF32(sourceString); + VERIFY_TEXT_REPLY_OK; + + // Successful UTF-32 with spec-wise allowed extra leading content in the Content-Type header value serverSideResponse.headers.removeAll(Header::ContentType); serverSideResponse.headers.append(Header::ContentType, - "text/plain; charset = \"UTF-32\";extraparameter=bar"_ba); + "text/plain; extraparameter=bar;charset = \"UT\\F-32\""_ba); serverSideResponse.body = encUTF32(sourceString); VERIFY_TEXT_REPLY_OK; |