androiddownloaddownload-manager

How to make sure if a download is resumable


I am creating a downloadaccelerator library Is there any way to know before starting a download from a link weather the server supports resuming downloads/downloading file reange . Because if it does then i ll use multipple connections and download ranges or else i ll download the whole file normally

thank you


Solution

  • Similar to GET header to get the required html page, we have something called as HEAD header.

    When you send a HEAD request for an URL we get a set of values for the URL

    Example: if you want to know details of http://www.wgz.org/chromatic/perl/IntroTestMore.pdf

    Send a HEAD command to the URL, the response will be

    Date: Mon, 03 Nov 2008 06:29:09 GMT
    Accept-Ranges: bytes
    ETag: "156046f-11889-3a578cd2bf2c0"
    Server: Apache
    Content-Length: 71817
    Content-Type: application/pdf
    Last-Modified: Thu, 11 Jul 2002 04:53:07 GMT
    Client-Date: Mon, 03 Nov 2008 06:29:10 GMT
    Client-Peer: 167.168.132.148:8080
    Client-Response-Num: 1
    

    Intresting Values: Accept-Ranges, Content-Length

    Accept-Ranges: bytes tells that server is ready to give files part by part as requested

    More info here: http://www.crazyengineers.com/community/threads/how-does-resume-download-work.7396/