jazzband / django-downloadview

Serve files with Django.
https://django-downloadview.readthedocs.io
Other
380 stars 58 forks source link

Support Lighttpd's X-Sendfile2 header: resume streaming #67

Open benoitbryon opened 10 years ago

benoitbryon commented 10 years ago

http://redmine.lighttpd.net/projects/1/wiki/Docs_ModFastCGI#X-Sendfile

If the HTTP client needs to resume a download it will send a HTTP header called "Range" In case of a download resume (for instance when using wget -c), the header will be like "bytes=2375680-" See RFC2616 section 14.35.2 http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.2

And

send the "X-Sendfile2: filename range" header (available since 1.4.24) The filename has to be urlencoded (including encoding ',' as '%2c': str_replace(',', '%2c', urlencode($path));) Range has the form "start-end" (inclusive end) or "start-" (from start until file end); you must always specify the range, use "0-" for the complete file. Example: X-Sendfile2: /tmp/test.txt 0-499 sends the first 500 bytes from /tmp/test.txt. You can send this header more than once with different parameters (or you can combine single values with ", " between them).