diff options
Diffstat (limited to 'tests/auto/qnetworkreply/tst_qnetworkreply.cpp')
-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() { |