diff options
author | Szabolcs David <davidsz@inf.u-szeged.hu> | 2020-01-07 17:12:18 +0100 |
---|---|---|
committer | Szabolcs David <davidsz@inf.u-szeged.hu> | 2020-01-20 13:01:08 +0100 |
commit | 47f63517d4bb10c0771a8009397df7d5e20ec5cc (patch) | |
tree | 01f9594dba369b61fc24c35114119d5385db12c6 /src/core/net/url_request_custom_job_proxy.cpp | |
parent | 075050991bbdc8c165b5ccf809516e3eaa5ee859 (diff) |
Support Range headers in custom URLRequestJobs
This is essential when Chromium tries to load media files in multiple jobs
over custom protocols, like qrc. Allow subsequent jobs to continue reading
media files from specified positions to avoid media glitches and errors.
Task-number: QTBUG-80234
Change-Id: I9a7e98c0cb08b2399b7928ecf026c0deb90a1bcb
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/net/url_request_custom_job_proxy.cpp')
-rw-r--r-- | src/core/net/url_request_custom_job_proxy.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/net/url_request_custom_job_proxy.cpp b/src/core/net/url_request_custom_job_proxy.cpp index 72d14450e..27fed7bf2 100644 --- a/src/core/net/url_request_custom_job_proxy.cpp +++ b/src/core/net/url_request_custom_job_proxy.cpp @@ -95,9 +95,14 @@ void URLRequestCustomJobProxy::reply(std::string mimeType, QIODevice *device) if (m_job->m_device && !m_job->m_device->isReadable()) m_job->m_device->open(QIODevice::ReadOnly); - qint64 size = m_job->m_device ? m_job->m_device->size() : -1; - if (size > 0) - m_job->set_expected_content_size(size); + if (m_job->m_firstBytePosition > 0) + m_job->m_device->seek(m_job->m_firstBytePosition); + + qint64 deviceSize = m_job->m_device ? m_job->m_device->size() : -1; + qint64 remainingBytes = deviceSize - m_job->m_firstBytePosition; + if (remainingBytes > 0) + m_job->set_expected_content_size(remainingBytes); + if (m_job->m_device && m_job->m_device->isReadable()) { m_started = true; m_job->NotifyHeadersComplete(); |