[Django] #30567: Start passing FileResponse.block_size to wsgi.file_wrapper

14 views
Skip to first unread message

Django

unread,
Jun 15, 2019, 5:10:00 PM6/15/19
to django-...@googlegroups.com
#30567: Start passing FileResponse.block_size to wsgi.file_wrapper
-------------------------------------+-------------------------------------
Reporter: Chris | Owner: nobody
Jerdonek |
Type: | Status: new
Cleanup/optimization |
Component: HTTP | Version: master
handling | Keywords:
Severity: Normal | block_size,wsgi.file_wrapper,FileResponse,wsgi
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I noticed that Django's `FileResponse` class has a `block_size` attribute
which can be customized by subclassing:
https://github.com/django/django/blob/415e899dc46c2f8d667ff11d3e54eff759eaded4/django/http/response.py#L393

but it's not passed to `wsgi.file_wrapper`. Only the `filelike` object is
passed:

{{{
response = environ['wsgi.file_wrapper'](response.file_to_stream)
}}}

(from:
https://github.com/django/django/blob/415e899dc46c2f8d667ff11d3e54eff759eaded4/django/core/handlers/wsgi.py#L144
)

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

Django

unread,
Jun 15, 2019, 5:11:37 PM6/15/19
to django-...@googlegroups.com
#30567: Start passing FileResponse.block_size to wsgi.file_wrapper
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
block_size,wsgi.file_wrapper,FileResponse,wsgi| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Chris Jerdonek:

Old description:

> I noticed that Django's `FileResponse` class has a `block_size` attribute
> which can be customized by subclassing:
> https://github.com/django/django/blob/415e899dc46c2f8d667ff11d3e54eff759eaded4/django/http/response.py#L393
>
> but it's not passed to `wsgi.file_wrapper`. Only the `filelike` object is
> passed:
>
> {{{
> response = environ['wsgi.file_wrapper'](response.file_to_stream)
> }}}
>
> (from:
> https://github.com/django/django/blob/415e899dc46c2f8d667ff11d3e54eff759eaded4/django/core/handlers/wsgi.py#L144
> )

New description:

I noticed that Django's `FileResponse` class has a `block_size` attribute
which can be customized by subclassing:
https://github.com/django/django/blob/415e899dc46c2f8d667ff11d3e54eff759eaded4/django/http/response.py#L393

but it's not passed to `wsgi.file_wrapper`. Only the `filelike` object is
passed:

{{{
#!python


response = environ['wsgi.file_wrapper'](response.file_to_stream)
}}}

(from:
https://github.com/django/django/blob/415e899dc46c2f8d667ff11d3e54eff759eaded4/django/core/handlers/wsgi.py#L144
)

--

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

Django

unread,
Jun 17, 2019, 2:00:28 AM6/17/19
to django-...@googlegroups.com
#30567: Start passing FileResponse.block_size to wsgi.file_wrapper.

-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
block_size,wsgi.file_wrapper,FileResponse,wsgi|
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Unreviewed => Accepted


Comment:

Seems reasonable, Thanks (see [https://modwsgi.readthedocs.io/en/develop
/user-guides/file-wrapper-extension.html?highlight=block_size#example-of-
wrapper-usage example-of-wrapper-usage]).

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

Django

unread,
Jul 22, 2019, 3:38:34 PM7/22/19
to django-...@googlegroups.com
#30567: Start passing FileResponse.block_size to wsgi.file_wrapper.
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Piotr
Type: | Domański
Cleanup/optimization | Status: assigned

Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
block_size,wsgi.file_wrapper,FileResponse,wsgi|
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Piotr Domański):

* owner: nobody => Piotr Domański
* status: new => assigned


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

Django

unread,
Jul 24, 2019, 1:12:57 PM7/24/19
to django-...@googlegroups.com
#30567: Start passing FileResponse.block_size to wsgi.file_wrapper.
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Piotr
Type: | Domański
Cleanup/optimization | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
block_size,wsgi.file_wrapper,FileResponse,wsgi| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Piotr Domański):

* has_patch: 0 => 1
* stage: Accepted => Ready for checkin


Comment:

Pull request: https://github.com/django/django/pull/11592

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

Django

unread,
Jul 24, 2019, 1:20:38 PM7/24/19
to django-...@googlegroups.com
#30567: Start passing FileResponse.block_size to wsgi.file_wrapper.
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Piotr
Type: | Domański
Cleanup/optimization | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
block_size,wsgi.file_wrapper,FileResponse,wsgi|
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Piotr Domański):

* stage: Ready for checkin => Accepted


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

Django

unread,
Jul 26, 2019, 1:57:45 AM7/26/19
to django-...@googlegroups.com
#30567: Start passing FileResponse.block_size to wsgi.file_wrapper.
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Piotr
Type: | Domański
Cleanup/optimization | Status: closed

Component: HTTP handling | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
block_size,wsgi.file_wrapper,FileResponse,wsgi|
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"4b4e68a7a6847e8b449923bb882bed01f0d7b2a8" 4b4e68a7]:
{{{
#!CommitTicketReference repository=""
revision="4b4e68a7a6847e8b449923bb882bed01f0d7b2a8"
Fixed #30567 -- Made WSGIHandler pass FileResponse.block_size to
wsgi.file_wrapper.
}}}

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

Reply all
Reply to author
Forward
0 new messages