diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-09-09 12:23:08 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-09-12 18:01:25 +0200 |
commit | aefd389bfdf7efcaf787d2cfb4683d7018cb377c (patch) | |
tree | 9f100c95cd16ab0edbe42802f575451d41ab1f31 /src/core/net | |
parent | 4ff07da88fa07258db9f591888b96b15b35c677a (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.
Pick-to: 6.4 6.4.0 6.3
Fixes: QTBUG-106461
Change-Id: Iac1233e6daa978c827c37a7fd3131e2fce764111
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/core/net')
-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 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; } |