How to create partial download in twisted?

丶灬走出姿态 提交于 2020-01-05 04:38:08

问题


How do you create multiple HTTPDownloader instance with partial download asynchronously? and does it assemble the file automatically after all download is done?


回答1:


You must use Range HTTP header:

Range. Request only part of an entity. Bytes are numbered from 0. Range: bytes=500-999

Ie. If you want download 1000 file in 4 parts, you will starts 4 downloads:

  1. 0-2499
  2. 2500-4999
  3. 5000-7499
  4. 7500-9999

And then simply join data from responses.

To check file size you can use HEAD method:

HEAD Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content.



来源:https://stackoverflow.com/questions/3328059/how-to-create-partial-download-in-twisted

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!