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>
This commit is contained in:
parent
f45ad0eeb3
commit
808acc07f2
@ -380,7 +380,8 @@ bool QNetworkReplyHttpImpl::canReadLine () const
|
||||
if (d->cacheLoadDevice)
|
||||
return d->cacheLoadDevice->canReadLine() || d->downloadMultiBuffer.canReadLine();
|
||||
|
||||
// FIXME zerocopy buffer?
|
||||
if (d->downloadZerocopyBuffer)
|
||||
return memchr(d->downloadZerocopyBuffer + d->downloadBufferReadPosition, '\n', d->downloadBufferCurrentSize - d->downloadBufferReadPosition);
|
||||
|
||||
return d->downloadMultiBuffer.canReadLine();
|
||||
}
|
||||
|
@ -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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user