The are two relevant feature requests (one is open, another is a duplicate of the first):
- Ticket #22479 – Support byte range requests in django.views.static.serve
- Ticket #23382 – Support byte range requests in django.views.static.serve
Both of the issues are based on the Google Group discussion.
The ticket is in a “hanging” state due to architectural concerns and since there is no consensus on whether this is really something that Django should support. Mostly because web-servers are capable of byte serving.
If you are still interested in the implementation, there is a not-yet-reviewed patch sent implementing a special RangedFileReader
class for returning the response in chunks using StreamingHttpResponse
, there is parsing and sanity checking for HTTP_RANGE
header:
You can try out the fork or use the solution as a base of your own.
FYI, there was an another attempt made here – it was not finished, but can be useful to review.
To parse Range
header, see:
werkzeug
‘sparse_range_header()
parse_range_header()
from the mentioned above PRhttpheader
‘sparse_range_header()
(see also Using HTTP range requests)