Content-Range to resume file of unknown length

I am creating a zip archive on the fly of unknown length from existing material (using Node), which is already compressed. Files are simply saved in the ZIP archive; ZIP is used for only one container. Therefore, caching the created ZIP files does not make sense - there is no real calculation.

Bye, OK. Now I want to allow resuming downloads , and I'm reading about the Accept-Range, Range, and Content-Range HTTP headers. A client with a broken download will request an open range, say: Range: bytes=8000000- .

How do I answer? My answer should include the Content-Range header, and there, according to RFC 2616 § 14.16 :

Unlike the values ​​of range byte specifiers (see section 14.35.1), byte-range-resp-spec MUST specify only one range and MUST contain absolute byte positions for both the first and last byte of the range.

Therefore, I can’t just send “everything from position X”, I have to indicate the last byte sent either by sending only a part of a known size, or by calculating the length in advance. Both ideas do not suit me. Is there any other possibility?

+4
source share
2 answers

Answering a question: it seems that I need to choose between (1) the encoding of the encoding of the file of unknown length or (2) knowing its Content-Length (or at least the size of the current part), which allows the resume of the download (as well as progress indicators) .

I can live with this - for each of my ZIP files the length will be the same, so I can save it somewhere and reuse it for subsequent downloads. I'm just surprised that the HTTP protocol does not allow resuming downloads of unknown length.

0
source

Response with "multipart / byteranges" Content-Type, including Content-Range fields for each part.

Reasoning:

  • When responding to requests with the "Range" header, successful partial responses should report 206 HTTP status code ( 14.35.1 Section "Byte ranges" )

  • The 206 response offers either a Content-Range header or a "multipart / byteranges" Content-Type ( 10.2.7 206 Partial content )

  • The header "Content-Range" cannot be added to the response, since it does not allow you to omit the end position, so the only left way is to use "multipart / byteranges" Content-Type

0
source

All Articles