0

I want to have a resumeable download of a file using PHP. As this post states i need to have a certain workflow to do that, so i added it.

Now the matter is that on initiating the download the downloadmanager recognizes that the download is resumeable (due to the "Accept-Range" - Header), but when starting off the resumed download it fails.

I now debugged the output of the headers being sent, but i can't find a reason why it won't work. Probably i have a bad view at the moment or the mistake is somewhere else, but i'd guess it's hidden here.

Request: bytes=2967529-
Header: HTTP/1.1 206 Partial Content
Header: content-type: application/x-rar-compressed
Header: Content-Type: application/octet-stream
Header: Cache-Control: private
Header: Accept-Ranges: bytes
Header: Content-Range: bytes 2967529-/52702041
Header: content-length: 52702041
Header: content-disposition: attachment; filename="XXX.rar"

Another attempt changed some headers but it still doesn't work:

Header: Content-Range: bytes 2967529-55669570/*
Header: content-length: 52702041

The content-length (and the last integer in the range) is the filesize where the offset is already deducted.

Kind regards

Community
  • 1
  • 1
James Cameron
  • 1,681
  • 25
  • 40

1 Answers1

0

I fixed the problem by myself. Indeed, the mistake was inside the headers.

I thought Content-Range and Content-Length was supposed to work like this:

Content-Range: bytes startbytes-totalbytes/bytestobesend
Content-Length: bytestobesent

Actually, it works like this:

Content-Range: bytes startbytes-totalbytes/totalbytes
Content-Length: totalbytes

(Where totalbytes is the complete filesize, not only the chapter that is sent)

James Cameron
  • 1,681
  • 25
  • 40