summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/access
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/network/access')
-rw-r--r--tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp67
-rw-r--r--tests/auto/network/access/qnetworkreply/BLACKLIST4
2 files changed, 71 insertions, 0 deletions
diff --git a/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp b/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp
index 3373324c19..ec965a61b2 100644
--- a/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp
+++ b/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp
@@ -28,6 +28,9 @@
#include <QtTest/QtTest>
+#include <QtCore/QBuffer>
+#include <QtCore/QByteArray>
+
#include "private/qhttpnetworkconnection_p.h"
class tst_QHttpNetworkReply: public QObject
@@ -36,6 +39,9 @@ class tst_QHttpNetworkReply: public QObject
private Q_SLOTS:
void parseHeader_data();
void parseHeader();
+
+ void parseEndOfHeader_data();
+ void parseEndOfHeader();
};
void tst_QHttpNetworkReply::parseHeader_data()
@@ -95,5 +101,66 @@ void tst_QHttpNetworkReply::parseHeader()
}
}
+class TestHeaderSocket : public QAbstractSocket
+{
+public:
+ explicit TestHeaderSocket(const QByteArray &input) : QAbstractSocket(QAbstractSocket::TcpSocket, Q_NULLPTR)
+ {
+ inputBuffer.setData(input);
+ inputBuffer.open(QIODevice::ReadOnly | QIODevice::Unbuffered);
+ open(QIODevice::ReadOnly | QIODevice::Unbuffered);
+ }
+
+ qint64 readData(char *data, qint64 maxlen) { return inputBuffer.read(data, maxlen); }
+
+ QBuffer inputBuffer;
+};
+
+class TestHeaderReply : public QHttpNetworkReply
+{
+public:
+ QHttpNetworkReplyPrivate *replyPrivate() { return static_cast<QHttpNetworkReplyPrivate *>(d_ptr.data()); }
+};
+
+void tst_QHttpNetworkReply::parseEndOfHeader_data()
+{
+ QTest::addColumn<QByteArray>("headers");
+ QTest::addColumn<qint64>("lengths");
+
+ QTest::newRow("CRLFCRLF") << QByteArray("Content-Type: text/html; charset=utf-8\r\n"
+ "Content-Length:\r\n 1024\r\n"
+ "Content-Encoding: gzip\r\n\r\nHTTPBODY")
+ << qint64(90);
+
+ QTest::newRow("CRLFLF") << QByteArray("Content-Type: text/html; charset=utf-8\r\n"
+ "Content-Length:\r\n 1024\r\n"
+ "Content-Encoding: gzip\r\n\nHTTPBODY")
+ << qint64(89);
+
+ QTest::newRow("LFCRLF") << QByteArray("Content-Type: text/html; charset=utf-8\r\n"
+ "Content-Length:\r\n 1024\r\n"
+ "Content-Encoding: gzip\n\r\nHTTPBODY")
+ << qint64(89);
+
+ QTest::newRow("LFLF") << QByteArray("Content-Type: text/html; charset=utf-8\r\n"
+ "Content-Length:\r\n 1024\r\n"
+ "Content-Encoding: gzip\n\nHTTPBODY")
+ << qint64(88);
+}
+
+void tst_QHttpNetworkReply::parseEndOfHeader()
+{
+ QFETCH(QByteArray, headers);
+ QFETCH(qint64, lengths);
+
+ TestHeaderSocket socket(headers);
+
+ TestHeaderReply reply;
+
+ QHttpNetworkReplyPrivate *replyPrivate = reply.replyPrivate();
+ qint64 headerBytes = replyPrivate->readHeader(&socket);
+ QCOMPARE(headerBytes, lengths);
+}
+
QTEST_MAIN(tst_QHttpNetworkReply)
#include "tst_qhttpnetworkreply.moc"
diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST
index 3ec580ddde..0605677e29 100644
--- a/tests/auto/network/access/qnetworkreply/BLACKLIST
+++ b/tests/auto/network/access/qnetworkreply/BLACKLIST
@@ -7,3 +7,7 @@ ubuntu-14.04
*
[backgroundRequestInterruption:ftp, bg, nobg]
*
+[authenticationCacheAfterCancel:http+socksauth]
+rhel-7.1
+[authenticationCacheAfterCancel:https+socksauth]
+rhel-7.1