DownloadOperation not resumed with correct data RRS feed

  • Question

  • Hello!

    Class DownloadOperation has two methods: Pause() and Resume(), what must pausing and resuming my download. But I have a next problem - after execution method Resume() properties Progress.BytesReceived of DownloadOperation object is reset and download begin from 0. Also properties Progress.HasRestarted set on true.

    How I can fix it and what is the causes of this behavior?


    public async void ResumeLoading()
                    Debug.WriteLine(this.DownloadOperation.Progress.BytesReceived);// write 495000 (as example)
                    Debug.WriteLine(DownloadOperation.Progress.HasRestarted);//write false
                    await Task.Delay(1000);
                    Debug.WriteLine(this.DownloadOperation.Progress.BytesReceived);//write 3000

    Friday, January 23, 2015 4:14 PM


All replies

  • https://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.backgroundtransfer.downloadoperation.resume.aspx


    This method can be called on a paused download operation to resume the download. The download operation will try to resume the download if possible. Only requests where the server accepts range-requests can resume. Otherwise the download is restarted.

    Friday, January 23, 2015 4:41 PM
  • Only Resumable downloads can be resumed. You can know if a download is resumable by looking at ResponseInformation.IsResumable

    A download is resumable when the server includes Accept-Ranges and ETag headers:

    HTTP/1.1 200 OK
    ETag: "asdfg"
    Accept-Ranges: bytes
    Content-Length: 1000000000
    Content-Type: text/plain; charset=UTF-8
    Date: Sat, 14 Feb 2015 20:03:51 GMT
    Connection: Keep-Alive

    Then, Background Transfer will include Range and If-Range headers in resume request:

    GET / HTTP/1.1
    Host: example.com
    Range: bytes=26524288-999999999
    If-Range: "asdfg"
    Connection: keep-alive

    Finally, server must reply with a "206 Partial Content" response and include Content-Range header:

    HTTP/1.1 206 Partial Content
    ETag: "asdfg"
    Accept-Ranges: bytes
    Content-Range: bytes 26524288-999999999/1000000000
    Content-Length: 973475712
    Content-Type: text/plain; charset=UTF-8
    Date: Sat, 14 Feb 2015 20:07:06 GMT
    Connection: Keep-Alive

    Saturday, February 14, 2015 8:11 PM