[Django] #30196: Make FileResponse always set Content-Disposition header.

15 views
Skip to first unread message

Django

unread,
Feb 20, 2019, 10:24:06 PM2/20/19
to django-...@googlegroups.com
#30196: Make FileResponse always set Content-Disposition header.
-------------------------------------+-------------------------------------
Reporter: Piotr | Owner: nobody
Kunicki |
Type: | Status: new
Cleanup/optimization |
Component: HTTP | Version: master
handling | Keywords: FileResponse file
Severity: Normal | response Content-Disposition header
Triage Stage: | attachment inline
Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
FileResponse currently sets the Content-Disposition header only if
as_attachment is true.

Setting it explicitly to, e.g. 'inline; filename="example.png"' in the
other case would allow the browser to set a default name for that inline
file in case a user attempts to download it with the 'Save image as...'
option.

That filename value is also visible in the title of the tab when image is
being viewed directly in Firefox (at least v56).

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

Django

unread,
Feb 20, 2019, 10:25:51 PM2/20/19
to django-...@googlegroups.com
#30196: Make FileResponse always set Content-Disposition header.
-------------------------------------+-------------------------------------
Reporter: Piotr Kunicki | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: FileResponse file | Triage Stage:
response Content-Disposition | Unreviewed
header attachment inline |

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Piotr Kunicki:

Old description:

> FileResponse currently sets the Content-Disposition header only if
> as_attachment is true.
>
> Setting it explicitly to, e.g. 'inline; filename="example.png"' in the
> other case would allow the browser to set a default name for that inline
> file in case a user attempts to download it with the 'Save image as...'
> option.
>
> That filename value is also visible in the title of the tab when image is
> being viewed directly in Firefox (at least v56).

New description:

FileResponse currently sets the Content-Disposition header only if
as_attachment is true.

Setting it explicitly to, e.g. 'inline; filename="example.png"' in the
other case would allow the browser to set a default name for that inline
file in case a user attempts to download it with the 'Save image as...'
option.

That filename value is also visible in the title of the tab when image is
being viewed directly in Firefox (at least v56).

Created a pull request: https://github.com/django/django/pull/11011

--

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

Django

unread,
Feb 20, 2019, 10:56:00 PM2/20/19
to django-...@googlegroups.com
#30196: Make FileResponse always set Content-Disposition header.
-------------------------------------+-------------------------------------
Reporter: Piotr Kunicki | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: FileResponse file | Triage Stage: Accepted
response Content-Disposition |
header attachment inline |

Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

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


Comment:

The feature request makes sense but it's still missing tests.

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

Django

unread,
Feb 21, 2019, 7:11:16 PM2/21/19
to django-...@googlegroups.com
#30196: Make FileResponse always set Content-Disposition header.
-------------------------------------+-------------------------------------
Reporter: Piotr Kunicki | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: FileResponse file | Triage Stage: Accepted
response Content-Disposition |
header attachment inline |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Piotr Kunicki):

Sorry for ''beginner'' questions, but: as in, you want me to add some unit
tests?
No problem, but wouldn't a single test be enough?
All this change does, after all, is setting Content-Disposition when
as_attachment=False, so checking if it works shouldn't require more.

I also noticed there's no unit test checking if setting a custom filename
works, so i added it to the same one test.

What else to add?

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

Django

unread,
Feb 22, 2019, 10:51:07 AM2/22/19
to django-...@googlegroups.com
#30196: Make FileResponse always set Content-Disposition header.
-------------------------------------+-------------------------------------
Reporter: Piotr Kunicki | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: FileResponse file | Triage Stage: Accepted
response Content-Disposition |
header attachment inline |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Piotr Kunicki):

* needs_tests: 1 => 0


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

Django

unread,
Feb 23, 2019, 6:56:52 PM2/23/19
to django-...@googlegroups.com
#30196: Make FileResponse always set Content-Disposition header.
-------------------------------------+-------------------------------------
Reporter: Piotr Kunicki | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: FileResponse file | Triage Stage: Accepted
response Content-Disposition |
header attachment inline |
Has patch: 1 | Needs documentation: 1

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

* needs_docs: 0 => 1
* easy: 1 => 0


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

Django

unread,
Feb 25, 2019, 8:23:01 PM2/25/19
to django-...@googlegroups.com
#30196: Make FileResponse always set Content-Disposition header.
-------------------------------------+-------------------------------------
Reporter: Piotr Kunicki | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: FileResponse file | Triage Stage: Accepted
response Content-Disposition |
header attachment inline |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Piotr Kunicki):

* needs_docs: 1 => 0


Comment:

Added documentation changes to the commit in PR.

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

Django

unread,
Apr 14, 2019, 6:14:12 PM4/14/19
to django-...@googlegroups.com
#30196: Make FileResponse always set Content-Disposition header.
-------------------------------------+-------------------------------------
Reporter: Piotr Kunicki | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: FileResponse file | Triage Stage: Ready for
response Content-Disposition | checkin
header attachment inline |

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tobias Kunze):

* stage: Accepted => Ready for checkin


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

Django

unread,
Apr 15, 2019, 4:42:46 PM4/15/19
to django-...@googlegroups.com
#30196: Make FileResponse always set Content-Disposition header.
-------------------------------------+-------------------------------------
Reporter: Piotr Kunicki | Owner: Piotr
Type: | Kunicki
Cleanup/optimization | Status: assigned

Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: FileResponse file | Triage Stage: Ready for
response Content-Disposition | checkin
header attachment inline |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tobias Kunze):

* owner: nobody => Piotr Kunicki
* status: new => assigned


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

Django

unread,
May 17, 2019, 6:08:02 AM5/17/19
to django-...@googlegroups.com
#30196: Make FileResponse always set Content-Disposition header.
-------------------------------------+-------------------------------------
Reporter: Piotr Kunicki | Owner: Piotr
Type: | Kunicki
Cleanup/optimization | Status: closed

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

Keywords: FileResponse file | Triage Stage: Ready for
response Content-Disposition | checkin
header attachment inline |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson <carlton.gibson@…>):

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


Comment:

In [changeset:"de4832c49b8a8cf00b2d602ab4d10c4ca69627bd" de4832c]:
{{{
#!CommitTicketReference repository=""
revision="de4832c49b8a8cf00b2d602ab4d10c4ca69627bd"
Fixed #30196 -- Made FileResponse set Content-Disposition inline if
filename is available.
}}}

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

Reply all
Reply to author
Forward
0 new messages