summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-09-09 12:23:08 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-09-13 06:41:37 +0000
commite0c0f791a10d73b53c4790a20b41f254331903c0 (patch)
treee7d51c6ea5c7768de30cfa60beaacd5b959fd66d /src
parentb7cf52cc9f84818913581f5a21769644a0e26fe9 (diff)
Fix using QNetworkReply with custom url schemes
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')
-rw-r--r--src/core/net/custom_url_loader_factory.cpp9
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 9873b979a..bd7d7dc58 100644
--- a/src/core/net/custom_url_loader_factory.cpp
+++ b/src/core/net/custom_url_loader_factory.cpp
@@ -380,13 +380,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;
}