QHttpSocketEngine: replace dummy buffer + read() with skip()

Change-Id: Iace00f478b0ea5dc3f874f337212b996af1e5104
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Alex Trotsenko 2017-09-12 20:18:44 +03:00
parent 58c14c4a7e
commit aa4e6345bb

View File

@ -572,18 +572,13 @@ void QHttpSocketEngine::slotSocketReadNotification()
}
if (d->state == ReadResponseContent) {
char dummybuffer[4096];
while (d->pendingResponseData) {
int read = d->socket->read(dummybuffer, qMin(sizeof(dummybuffer), (size_t)d->pendingResponseData));
if (read == 0)
return;
if (read == -1) {
d->socket->disconnectFromHost();
emitWriteNotification();
return;
}
d->pendingResponseData -= read;
qint64 skipped = d->socket->skip(d->pendingResponseData);
if (skipped == -1) {
d->socket->disconnectFromHost();
emitWriteNotification();
return;
}
d->pendingResponseData -= uint(skipped);
if (d->pendingResponseData > 0)
return;
if (d->reply->d_func()->statusCode == 407)