diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2011-07-05 13:07:30 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-05 17:03:32 +0200 |
commit | 808acc07f25f167b0f90ce9f2cdfe12c4bb09cd0 (patch) | |
tree | b8bdec63f69533fbf1df38668a3e90cf2f89f20e /tests/auto/qnetworkreply | |
parent | f45ad0eeb3e298df731bc4d8dffe188b21500ea4 (diff) |
QNAM HTTP: Fix canReadLine() for zerocopy
Change-Id: I16cf25c72b3fa16649c3e4e0f4d4b08ad7ce360d
Reviewed-on: http://codereview.qt.nokia.com/1161
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'tests/auto/qnetworkreply')
-rw-r--r-- | tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 3b31e84556..782d533bbf 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -348,6 +348,7 @@ private Q_SLOTS: void getFromHttpIntoBuffer(); void getFromHttpIntoBuffer2_data(); void getFromHttpIntoBuffer2(); + void getFromHttpIntoBufferCanReadLine(); void ioGetFromHttpWithoutContentLength(); @@ -5824,6 +5825,33 @@ void tst_QNetworkReply::getFromHttpIntoBuffer2() } +void tst_QNetworkReply::getFromHttpIntoBufferCanReadLine() +{ + QString header("HTTP/1.0 200 OK\r\nContent-Length: 7\r\n\r\nxxx\nxxx"); + + MiniHttpServer server(header.toAscii()); + server.doClose = true; + + QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort()))); + request.setAttribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute, 1024*1024*128); // 128 MB is max allowed + QNetworkReplyPtr reply = manager.get(request); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(reply->error(), QNetworkReply::NoError); + QVERIFY(reply->canReadLine()); + QCOMPARE(reply->read(1), QByteArray("x")); + QVERIFY(reply->canReadLine()); + QCOMPARE(reply->read(3), QByteArray("xx\n")); + QVERIFY(!reply->canReadLine()); + QCOMPARE(reply->readAll(), QByteArray("xxx")); + QVERIFY(!reply->canReadLine()); +} + + + // Is handled somewhere else too, introduced this special test to have it more accessible void tst_QNetworkReply::ioGetFromHttpWithoutContentLength() { |