Reputation: 91
How do I download a large file in chunks parallelly in Qt. So that the file download time is reduced.
Upvotes: 5
Views: 5438
Reputation: 8147
Assuming you are using QNetwork and the download is an HTTP GET you will need to do the following:
Content-Length
) and check the server supports Range requests (Accept-Ranges
)Range
header based on the size of the contentTo enable HTTP pipelining on your requests by setting the HttpPipeliningAllowedAttribute
attribute:
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
Set the range headers:
req.setRawHeader("Range", "bytes=0-499");
Upvotes: 14