diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2020-05-13 11:04:28 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2021-06-12 00:04:04 +0200 |
commit | 6f25051536c1636688a0a0939196007aac34676d (patch) | |
tree | 390fc3fc4e0147a51d56aee6d563614b77981b6a /src/network/access/qhttp2protocolhandler.cpp | |
parent | f9b867216ba2728ff993020599f5062e2f023de1 (diff) |
QNetworkReply: Decompress when reading
Rather than when the data is received. Source compatibility is
achieved through double-decompressing the data. This lets us know
how many bytes are available just as before but without having the
uncompressed data left in memory.
Fixes: QTBUG-83269
Change-Id: I352bd09581614c582e4628243e2a0e895ba4946b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network/access/qhttp2protocolhandler.cpp')
-rw-r--r-- | src/network/access/qhttp2protocolhandler.cpp | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp index aaa7b58ac4..3b28775466 100644 --- a/src/network/access/qhttp2protocolhandler.cpp +++ b/src/network/access/qhttp2protocolhandler.cpp @@ -1233,13 +1233,8 @@ void QHttp2ProtocolHandler::updateStream(Stream &stream, const HPack::HttpHeader if (QHttpNetworkReply::isHttpRedirect(statusCode) && redirectUrl.isValid()) httpReply->setRedirectUrl(redirectUrl); - if (httpReplyPrivate->isCompressed() && httpRequest.d->autoDecompress) { + if (httpReplyPrivate->isCompressed() && httpRequest.d->autoDecompress) httpReplyPrivate->removeAutoDecompressHeader(); - httpReplyPrivate->decompressHelper.setEncoding( - httpReplyPrivate->headerField("content-encoding")); - httpReplyPrivate->decompressHelper.setMinimumArchiveBombSize( - httpReplyPrivate->request.minimumArchiveBombSize()); - } if (QHttpNetworkReply::isHttpRedirect(statusCode)) { // Note: This status code can trigger uploadByteDevice->reset() in @@ -1276,27 +1271,12 @@ void QHttp2ProtocolHandler::updateStream(Stream &stream, const Frame &frame, if (const auto length = frame.dataSize()) { const char *data = reinterpret_cast<const char *>(frame.dataBegin()); - auto &httpRequest = stream.request(); auto replyPrivate = httpReply->d_func(); replyPrivate->totalProgress += length; const QByteArray wrapped(data, length); - if (httpRequest.d->autoDecompress && replyPrivate->isCompressed()) { - Q_ASSERT(replyPrivate->decompressHelper.isValid()); - - replyPrivate->decompressHelper.feed(wrapped); - while (replyPrivate->decompressHelper.hasData()) { - QByteArray output(4 * 1024, Qt::Uninitialized); - qint64 read = replyPrivate->decompressHelper.read(output.data(), output.size()); - if (read > 0) { - output.resize(read); - replyPrivate->responseData.append(std::move(output)); - } - } - } else { - replyPrivate->responseData.append(wrapped); - } + replyPrivate->responseData.append(wrapped); if (replyPrivate->shouldEmitSignals()) { if (connectionType == Qt::DirectConnection) { |