diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-09-09 12:23:08 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-09-13 00:43:07 +0000 |
commit | d72c6f2c65e3111a841cbc6cfdd1c1e005f56458 (patch) | |
tree | b949267e765ebbb301f638e6be199f0b2b248fc9 /src/core/net/custom_url_loader_factory.cpp | |
parent | 9327dcb9b83a894b945d883a1acf4f26edacb15c (diff) |
Fix using QNetworkReply with custom url schemesv6.2.6-lts-lgpl
Sequential QIODevices are allowed to report atEnd() when they have no
data to read, but add more data later.
To avoid a regression with our own tests, treat a read error from a
sequential device at end, as end-of-data.
Fixes: QTBUG-106461
Change-Id: Iac1233e6daa978c827c37a7fd3131e2fce764111
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
(cherry picked from commit aefd389bfdf7efcaf787d2cfb4683d7018cb377c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/core/net/custom_url_loader_factory.cpp')
-rw-r--r-- | src/core/net/custom_url_loader_factory.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core/net/custom_url_loader_factory.cpp b/src/core/net/custom_url_loader_factory.cpp index d607da656..892f21dac 100644 --- a/src/core/net/custom_url_loader_factory.cpp +++ b/src/core/net/custom_url_loader_factory.cpp @@ -416,13 +416,20 @@ private: m_totalBytesRead += bytesRead; m_client->OnTransferSizeUpdated(m_totalBytesRead); - if (m_device->atEnd() || (m_maxBytesToRead > 0 && m_totalBytesRead >= m_maxBytesToRead)) { + const bool deviceAtEnd = m_device->atEnd(); + if ((deviceAtEnd && !m_device->isSequential()) + || (m_maxBytesToRead > 0 && m_totalBytesRead >= m_maxBytesToRead)) { OnTransferComplete(MOJO_RESULT_OK); return true; // Done with reading } if (readResult == 0) return false; // Wait for readyRead + if (readResult < 0 && deviceAtEnd && m_device->isSequential()) { + // Failure on read, and sequential device claiming to be at end, so treat it as a successful end-of-data. + OnTransferComplete(MOJO_RESULT_OK); + return true; // Done with reading + } if (readResult < 0) break; } |