summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Rosendahl <ext-sami.1.rosendahl@nokia.com>2012-01-05 15:48:12 +0200
committerQt by Nokia <qt-info@nokia.com>2012-01-06 04:43:05 +0100
commite6b9382ae2f6c8a6f83fa724168af467eed073cf (patch)
tree97c2ef301a50258681e0f195b701937119209b49
parentd55cdcd59fdddd660193ddff40fbd52bef57c0c9 (diff)
Add regression test for QTBUG-22660
QHttpNetworkReply crashed in Qt4.7 and 4.8 if a HTTP server responded with gzip-encoded empty content without defining Content-Length in the response header. This commit adds the test for the problem as a regression test to Qt5. Change-Id: Iddfb970a31d92a66fd1dd524811cf54bb06e5157 Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com>
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index b7ba7f061e..6ed241175d 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -369,6 +369,7 @@ private Q_SLOTS:
void qtbug15311doubleContentLength();
void qtbug18232gzipContentLengthZero();
+ void qtbug22660gzipNoContentLengthEmptyContent();
void synchronousRequest_data();
void synchronousRequest();
@@ -6363,6 +6364,28 @@ void tst_QNetworkReply::qtbug18232gzipContentLengthZero()
QCOMPARE(reply->readAll(), QByteArray());
}
+// Reproduced a crash in QHttpNetworkReplyPrivate::gunzipBodyPartiallyEnd
+// where zlib inflateEnd was called for uninitialized zlib stream
+void tst_QNetworkReply::qtbug22660gzipNoContentLengthEmptyContent()
+{
+ // Response with no Content-Length in header and empty content
+ QByteArray response("HTTP/1.0 200 OK\r\nContent-Encoding: gzip\r\n\r\n");
+ 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(0));
+ QVERIFY(!reply->header(QNetworkRequest::ContentLengthHeader).isValid());
+ QCOMPARE(reply->readAll(), QByteArray());
+}
+
void tst_QNetworkReply::synchronousRequest_data()
{
QTest::addColumn<QUrl>("url");