[Django] #22479: Support byte range requests in django.views.static.serve

44 views
Skip to first unread message

Django

unread,
Apr 20, 2014, 11:17:11 PM4/20/14
to django-...@googlegroups.com
#22479: Support byte range requests in django.views.static.serve
-------------------------------+--------------------
Reporter: slurms | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
As supported by this google groups discussions:
https://groups.google.com/d/msg/django-developers/NZ1qTkZ6vok/fhdz7rTtL1EJ

--
Ticket URL: <https://code.djangoproject.com/ticket/22479>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 20, 2014, 11:17:45 PM4/20/14
to django-...@googlegroups.com
#22479: Support byte range requests in django.views.static.serve
-------------------------------+------------------------------------

Reporter: slurms | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by slurms):

* needs_docs: => 1
* needs_better_patch: => 0
* needs_tests: => 1
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/22479#comment:1>

Django

unread,
Apr 21, 2014, 9:43:56 AM4/21/14
to django-...@googlegroups.com
#22479: Support byte range requests in django.views.static.serve
-------------------------------+------------------------------------
Reporter: slurms | Owner: slurms
Type: New feature | Status: assigned

Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by slurms):

* owner: nobody => slurms
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* status: new => assigned


Comment:

Pull request here: https://github.com/django/django/pull/2594.

--
Ticket URL: <https://code.djangoproject.com/ticket/22479#comment:2>

Django

unread,
Apr 21, 2014, 9:53:29 AM4/21/14
to django-...@googlegroups.com
#22479: Support byte range requests in django.views.static.serve
-------------------------------+------------------------------------
Reporter: slurms | Owner: slurms
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by timo):

Did you have any thoughts on adding gunicorn support for runserver
(#21978) as a possible way to avoid this?

--
Ticket URL: <https://code.djangoproject.com/ticket/22479#comment:3>

Django

unread,
Apr 21, 2014, 10:11:17 AM4/21/14
to django-...@googlegroups.com
#22479: Support byte range requests in django.views.static.serve
-------------------------------+------------------------------------
Reporter: slurms | Owner: slurms
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by slurms):

Does gunicorn support it? I'm not sure it does (there are no mentions of
"Range" in the source at all), in which case it's not avoidable unless we
add support into gunicorn instead?

--
Ticket URL: <https://code.djangoproject.com/ticket/22479#comment:4>

Django

unread,
Apr 21, 2014, 8:45:00 PM4/21/14
to django-...@googlegroups.com
#22479: Support byte range requests in django.views.static.serve
-------------------------------+------------------------------------
Reporter: slurms | Owner: slurms
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by timo):

* cc: timo (added)


Comment:

I don't know, but if we are adding runserver support for something that's
not even supported by what I think is a fairly common web server, that
seems like it will only encourage more people to use runserver in
production.

I'd echo Russ's sentiments from the django-developers thread: "rather than
add a bunch of features to a view in Django and then try to describe when
you shouldn't use it, I'd prefer to use that effort to replace the
devserver with something equally easy to use, but based off a base that is
an actual real live web server. That way, we'd end up with a "devserver",
but it would be an actual server, not a hack with a bunch of "please don't
actually use this" warnings, we don't end up spending a bunch of time
developing a feature that is already implemented better elsewhere, and it
would be one step closer to having production mirror development."

Would be great to at least do some investigation to see if this might be
feasible even if gunicorn isn't the ultimate answer.

--
Ticket URL: <https://code.djangoproject.com/ticket/22479#comment:5>

Django

unread,
Apr 22, 2014, 2:50:07 AM4/22/14
to django-...@googlegroups.com
#22479: Support byte range requests in django.views.static.serve
-------------------------------+------------------------------------
Reporter: slurms | Owner: slurms
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by slurms):

Good points, it would be great if we could get closer to dev/prod parity.
But sometimes I don't have a need for something rock-solid and production
tested, and instead I just want things to "easily" work. I don't think
gunicorn or the 'static' python library (used by dj_static) support
partial content, and I've only had the need for it to be supported
recently due to serving video content on a small internal application.
This internal application is still reverse proxied via nginx, and serving
content via gunicorn and `django.views.static.serve`. Werkzeug does
support partial content, but not for multipart/byterange requests (not
sure if this is a big deal).

The use-case for supporting it in `django.views.static.serve` is that this
application of ours runs in a container via docker. Without the support I
am faced with two decisions: I could map out the static and media dirs to
the host, and share the filesystem from the host to our nginx server and
serve it like that, or run an instance of nginx (or another http server)
directly within the container. Both of the options are time-consuming,
require oodles of extra configuration, and are probably not ideal. We just
need something simple that works for serving video content that supports
seeking within the video. The application won't be serving millions of
requests. If it was, I certainly wouldn't be using this support, I would
opt for a different solution. But it doesn't mean we shouldn't support it
at all :).

It would be good to move away from the devserver, but also, it would be
useful to support partial content in `django.views.static.serve` so that
things just work in the meantime. Maybe not ideal, but pragmatic?

--
Ticket URL: <https://code.djangoproject.com/ticket/22479#comment:6>

Django

unread,
Aug 29, 2014, 3:01:55 AM8/29/14
to django-...@googlegroups.com
#22479: Support byte range requests in django.views.static.serve
-------------------------------+------------------------------------
Reporter: slurms | Owner: slurms
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by claudep):

#23382 was closed as duplicate, and has a different patch proposed:
https://github.com/satchamo/django/commit/2ce75c5c4bee2a858c0214d136bfcd351fcde11d

--
Ticket URL: <https://code.djangoproject.com/ticket/22479#comment:7>

Django

unread,
Sep 18, 2014, 5:09:21 AM9/18/14
to django-...@googlegroups.com
#22479: Support byte range requests in django.views.static.serve
-------------------------------+------------------------------------
Reporter: slurms | Owner: slurms
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by alper):

I would settle for a separate package that does this, but as it stands now
for trying things out having to setup nginx on my local machine is a bit
too much work.

--
Ticket URL: <https://code.djangoproject.com/ticket/22479#comment:8>

Django

unread,
Oct 1, 2014, 5:14:29 PM10/1/14
to django-...@googlegroups.com
#22479: Support byte range requests in django.views.static.serve
-------------------------------+------------------------------------
Reporter: slurms | Owner: slurms
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by mdj2):

What is the preferred way to implement this feature? I went the simplest
route and hacked on just `django.views.static.serve` whereas slurms
creates a reusable PartialHttpResponse class. My implementation does not
support multipart/byteranges requests, but slurms' does. (I don't know of
any user-agent that makes those kinds of requests though.)

--
Ticket URL: <https://code.djangoproject.com/ticket/22479#comment:9>

Django

unread,
Mar 14, 2015, 11:36:46 AM3/14/15
to django-...@googlegroups.com
#22479: Support byte range requests in django.views.static.serve
-------------------------------+------------------------------------
Reporter: slurms | Owner: slurms
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by collinanderson):

* cc: cmawebsite@… (added)


Comment:

I also have some rough, but working code here:
https://github.com/collinanderson/djfiles/blob/master/djfiles.py

--
Ticket URL: <https://code.djangoproject.com/ticket/22479#comment:10>

Django

unread,
May 11, 2017, 4:30:09 PM5/11/17
to django-...@googlegroups.com
#22479: Support byte range requests in django.views.static.serve
-------------------------------+-----------------------------------------
Reporter: Nick Sandford | Owner: Nick Sandford

Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------------
Changes (by ):

* cc: amlau@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/22479#comment:11>

Django

unread,
Mar 21, 2023, 5:32:42 AM3/21/23
to django-...@googlegroups.com
#22479: Support byte range requests in django.views.static.serve
-------------------------------+------------------------------------
Reporter: Nick Sandford | Owner: (none)

Type: New feature | Status: new
Component: HTTP handling | Version: dev

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* owner: Nick Sandford => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/22479#comment:12>

Reply all
Reply to author
Forward
0 new messages