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.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.cpp')
-rw-r--r-- | src/core/net/url_request_custom_job.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/net/url_request_custom_job.cpp b/src/core/net/url_request_custom_job.cpp index 607e8d232..0d4ac620f 100644 --- a/src/core/net/url_request_custom_job.cpp +++ b/src/core/net/url_request_custom_job.cpp @@ -62,6 +62,7 @@ URLRequestCustomJob::URLRequestCustomJob(URLRequest *request, : URLRequestJob(request, networkDelegate) , m_proxy(new URLRequestCustomJobProxy(this, scheme, profileAdapter)) , m_device(nullptr) + , m_firstBytePosition(0) , m_error(0) , m_pendingReadSize(0) , m_pendingReadPos(0) @@ -184,6 +185,19 @@ bool URLRequestCustomJob::IsRedirectResponse(GURL *location, int *http_status_co return false; } +void URLRequestCustomJob::SetExtraRequestHeaders(const HttpRequestHeaders &headers) +{ + std::string rangeHeader; + if (headers.GetHeader(HttpRequestHeaders::kRange, &rangeHeader)) { + std::vector<HttpByteRange> ranges; + if (HttpUtil::ParseRangeHeader(rangeHeader, &ranges)) { + // Chromium doesn't support multiple range requests in one single URL request. + if (ranges.size() == 1) + m_firstBytePosition = ranges[0].first_byte_position(); + } + } +} + int URLRequestCustomJob::ReadRawData(IOBuffer *buf, int bufSize) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |