summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-11-13 13:38:49 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-11-13 15:52:54 (GMT)
commit76055d4e4a3023ef6390d85a02688bb11df57284 (patch)
tree6ae6e511c8a4fb5d547bea26c261ff1b49b16a07 /tests
parent57ad39ec62175eeea023ca802448ebb1605dca23 (diff)
downloadQt-76055d4e4a3023ef6390d85a02688bb11df57284.zip
Qt-76055d4e4a3023ef6390d85a02688bb11df57284.tar.gz
Qt-76055d4e4a3023ef6390d85a02688bb11df57284.tar.bz2
QNAM HTTP: Ignore double content-length headers
Task-number: QTBUG-15311 Reviewed-by: ogoffart
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index a986438..41b3e0a 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -301,6 +301,8 @@ private Q_SLOTS:
void httpWithNoCredentialUsage();
+ void qtbug15311doubleContentLength();
+
// NOTE: This test must be last!
void parentingRepliesToTheApp();
};
@@ -4724,6 +4726,26 @@ void tst_QNetworkReply::httpWithNoCredentialUsage()
QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError);
}
+void tst_QNetworkReply::qtbug15311doubleContentLength()
+{
+ QByteArray response("HTTP/1.0 200 OK\r\nContent-Length: 3\r\nServer: bogus\r\nContent-Length: 3\r\n\r\nABC");
+ MiniHttpServer server(response);
+ server.doClose = true;
+
+ QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
+ QNetworkReplyPtr reply = manager.get(request);
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(reply->isFinished());
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QCOMPARE(reply->size(), qint64(3));
+ QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), qint64(3));
+ QCOMPARE(reply->rawHeader("Content-length"), QByteArray("3, 3"));
+ QCOMPARE(reply->readAll(), QByteArray("ABC"));
+}
+
// NOTE: This test must be last testcase in tst_qnetworkreply!