summaryrefslogtreecommitdiffstats
path: root/src/network/access
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2022-09-09 13:23:59 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2022-09-12 13:06:50 +0200
commit5387b88aa96d2096a3423190d1f1e5bdd2c52052 (patch)
tree45df9d05301742b7968f7a16411c3067e28bf4fc /src/network/access
parentac0088aaac16c0a9e0db26a190ea6f49f83a54e2 (diff)
QNetworkReply: Fix missing final emission of readyRead
If we receive compressed data we will decompress it as it comes in, in some cases the final byte we receive doesn't actually contribute to the final output. If this byte is handled by itself then, when combined with QNetworkReply's signal compression, we ended up not emitting the readyRead signal for any of the data we received while compressing the signals. So, instead of relying on checking difference in bytes downloaded for each batch of data received we keep track of how much data we had received the last time we emitted readyRead. Pick-to: 6.3 6.4 6.4.0 Fixes: QTBUG-106354 Change-Id: I4777be29b46bf0de968667e9de9d975c735ac6e6 Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp6
-rw-r--r--src/network/access/qnetworkreplyhttpimpl_p.h4
2 files changed, 6 insertions, 4 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 08ef1866bd..e609653aa4 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -1035,9 +1035,6 @@ void QNetworkReplyHttpImplPrivate::replyDownloadData(QByteArray d)
// cache this, we need it later and it's invalidated when dealing with compressed data
auto dataSize = d.size();
- // Grab this to compare later (only relevant for compressed data) in case none of the data
- // will be propagated to the user
- const qint64 previousBytesDownloaded = bytesDownloaded;
if (cacheEnabled && isCachingAllowed() && !cacheSaveDevice)
initCacheSaveDevice();
@@ -1121,11 +1118,12 @@ void QNetworkReplyHttpImplPrivate::replyDownloadData(QByteArray d)
// This can occur when downloading compressed data as some of the data may be the content
// encoding's header. Don't emit anything for this.
- if (previousBytesDownloaded == bytesDownloaded) {
+ if (lastReadyReadEmittedSize == bytesDownloaded) {
if (readBufferMaxSize)
emit q->readBufferFreed(dataSize);
return;
}
+ lastReadyReadEmittedSize = bytesDownloaded;
QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
diff --git a/src/network/access/qnetworkreplyhttpimpl_p.h b/src/network/access/qnetworkreplyhttpimpl_p.h
index 55953ae878..11897d1420 100644
--- a/src/network/access/qnetworkreplyhttpimpl_p.h
+++ b/src/network/access/qnetworkreplyhttpimpl_p.h
@@ -200,6 +200,10 @@ public:
qint64 bytesDownloaded;
qint64 bytesBuffered;
+ // We use this to keep track of whether or not we need to emit readyRead
+ // when we deal with signal compression (delaying emission) + decompressing
+ // data (potentially receiving bytes that don't end up in the final output):
+ qint64 lastReadyReadEmittedSize = 0;
QTimer *transferTimeout;