[Django] #16470: RFC6266 Support

18 views
Skip to first unread message

Django

unread,
Jul 15, 2011, 9:12:22 AM7/15/11
to django-...@googlegroups.com
#16470: RFC6266 Support
-------------------------+--------------------------------------
Reporter: mnot@… | Owner: nobody
Type: New feature | Status: new
Milestone: | Component: Internationalization
Version: 1.3 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------+--------------------------------------
RFC6266, recently published by the IETF HTTPbis WG, describes a way to use
the Content-Disposition header in HTTP in a manner whereby almost all
current browsers can handle files (e.g., downloading with disposition
'attachment') that have non-ASCII characters in them, with other browsers
using an ASCII fallback.

Django currently does not have an API for setting Content-Disposition,
although there are a few references to it in the documentation. Adding
such an API would allow Django sites to download files in any language
easily.

Additionally, there's advice in the RFC that, properly implemented in a
Django API, would help sites avoid common pitfalls.

For more information, see:
http://trac.tools.ietf.org/wg/httpbis/trac/wiki/ContentDispositionProducerAdvice

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

Django

unread,
Jul 15, 2011, 9:22:24 AM7/15/11
to django-...@googlegroups.com
#16470: RFC6266 Support
-------------------------------------+-------------------------------------
Reporter: mnot@… | Owner: nobody
Type: New | Status: new
feature | Component:
Milestone: | Internationalization
Version: 1.3 | Severity: Normal
Resolution: | Keywords:
Triage Stage: | Has patch: 0
Unreviewed | Needs tests: 0
Needs documentation: 0 | Easy pickings: 0
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by jreschke):

* cc: jreschke (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


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

Django

unread,
Jul 15, 2011, 9:24:16 AM7/15/11
to django-...@googlegroups.com
#16470: RFC6266 Support
---------------------------------------+-------------------------------
Reporter: mnot@… | Owner: nobody
Type: New feature | Status: new
Milestone: | Component: HTTP handling
Version: 1.3 | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+-------------------------------
Changes (by aaugustin):

* component: Internationalization => HTTP handling
* stage: Unreviewed => Accepted


Comment:

This is a very common problem for developers, and I think it's in the
realm of what Django should do. I guess it means adding a method to
`HttpResponse`.

If the implementation isn't completely obvious, please start a discussion
to django-developers to ensure consensus.

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

Django

unread,
Jul 15, 2011, 10:01:23 AM7/15/11
to django-...@googlegroups.com
#16470: RFC6266 Support
---------------------------------------+-------------------------------
Reporter: mnot@… | Owner: nobody
Type: New feature | Status: new
Milestone: | Component: HTTP handling
Version: 1.3 | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+-------------------------------

Comment (by anonymous):

Mark had discussed this with me over twitter/email a couple days ago.
He's got an example implementation here:
https://github.com/mnot/sweet/blob/master/lib/index.js

I was thinking of trying to keep the existing API of dict key/value as
header/value pair, but having `__setitem__` do some special-casing on
Content-Disposition. This would allow do something sensible for all
existing code, and we could still add an extra method if people wanted
finder control over the fallback filename.

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

Django

unread,
Mar 29, 2012, 3:13:04 PM3/29/12
to django-...@googlegroups.com
#16470: RFC6266 Support
-------------------------------+------------------------------------
Reporter: mnot@… | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: 1.3
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Clueless):

This seems to be special case of the encoding in
http://tools.ietf.org/html/rfc5987

Seems to me that whatever solution we come up with should generalize to
any header that allows RFC 5987-style encodings.

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

Django

unread,
Nov 6, 2015, 10:42:13 AM11/6/15
to django-...@googlegroups.com
#16470: RFC5987/RFC6266 Support (Content-Disposition headers)
-------------------------------+------------------------------------

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

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

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

Django

unread,
Mar 30, 2018, 11:49:34 AM3/30/18
to django-...@googlegroups.com
#16470: RFC5987/RFC6266 Support (Content-Disposition headers)
-------------------------------+------------------------------------
Reporter: mnot@… | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: 1.3
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by Claude Paroz):

Now that we have a [https://docs.djangoproject.com/en/2.0/ref/request-
response/#fileresponse-objects FileResponse] subclass, what about adding a
parameter to this subclass which would then set the `Content-Disposition`
header appropriately? Would that satisfy most use cases?

The [https://docs.djangoproject.com/en/2.0/howto/outputting-pdf/ PDF
output example] could be then rewritten as:
{{{
import io
from reportlab.pdfgen import canvas
from django.http import FileResponse

def some_view(request):
# Create a file-like buffer to receive PDF data
buffer = io.BytesIO()

# Create the PDF object, using the buffer as its "file."
p = canvas.Canvas(buffer)

# Draw things on the PDF. Here's where the PDF generation happens.
# See the ReportLab documentation for the full list of functionality.
p.drawString(100, 100, "Hello world.")

# Close the PDF object cleanly, and we're done.
p.showPage()
p.save()
return FileResponse(buffer, as_attachment=True,
filename="somefilename.pdf")
}}}

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

Django

unread,
Mar 30, 2018, 12:19:35 PM3/30/18
to django-...@googlegroups.com
#16470: RFC5987/RFC6266 Support (Content-Disposition headers)
-------------------------------+------------------------------------
Reporter: mnot@… | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* version: 1.3 => master


Comment:

Claudep I think that would make sense.

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

Django

unread,
Mar 30, 2018, 12:26:23 PM3/30/18
to django-...@googlegroups.com
#16470: RFC5987/RFC6266 Support (Content-Disposition headers)
-------------------------------+------------------------------------
Reporter: mnot@… | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by Claude Paroz):

[https://github.com/claudep/django/commit/59938909dc8856021e938720724bd17042112cc2
POC commit].

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

Django

unread,
Mar 30, 2018, 1:43:08 PM3/30/18
to django-...@googlegroups.com
#16470: RFC5987/RFC6266 Support (Content-Disposition headers)
-------------------------------+------------------------------------
Reporter: mnot@… | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* has_patch: 0 => 1


Comment:

Made a [https://github.com/django/django/pull/9839 PR] with my commit.

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

Django

unread,
May 14, 2018, 10:34:22 PM5/14/18
to django-...@googlegroups.com
#16470: Make FileResponse set the Content-Disposition header
-------------------------------------+-------------------------------------

Reporter: mnot@… | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

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

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

* stage: Accepted => Ready for checkin


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

Django

unread,
May 15, 2018, 12:12:39 PM5/15/18
to django-...@googlegroups.com
#16470: Make FileResponse set the Content-Disposition header
-------------------------------------+-------------------------------------
Reporter: mnot@… | Owner: nobody
Type: New feature | Status: closed

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

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

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


Comment:

In [changeset:"a177f854c34718e473bcd0a2dc6c4fd935c8e327" a177f854]:
{{{
#!CommitTicketReference repository=""
revision="a177f854c34718e473bcd0a2dc6c4fd935c8e327"
Fixed #16470 -- Allowed FileResponse to auto-set some Content headers.

Thanks Simon Charette, Jon Dufresne, and Tim Graham for the reviews.
}}}

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

Django

unread,
Sep 1, 2018, 9:14:52 AM9/1/18
to django-...@googlegroups.com
#16470: Make FileResponse set the Content-Disposition header
-------------------------------------+-------------------------------------
Reporter: mnot@… | Owner: nobody

Type: New feature | Status: closed
Component: HTTP handling | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by Claude Paroz <claude@…>):

In [changeset:"ee52044a278885bd9455dd59b1e16c5d5e2d68ce" ee52044a]:
{{{
#!CommitTicketReference repository=""
revision="ee52044a278885bd9455dd59b1e16c5d5e2d68ce"
Refs #16470 -- Fixed typo in a FileResponse test.
}}}

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

Django

unread,
Sep 1, 2018, 9:17:09 AM9/1/18
to django-...@googlegroups.com
#16470: Make FileResponse set the Content-Disposition header
-------------------------------------+-------------------------------------
Reporter: mnot@… | Owner: nobody

Type: New feature | Status: closed
Component: HTTP handling | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by Claude Paroz <claude@…>):

In [changeset:"231c595bde342e507091167387fba7ba1882b9c9" 231c595]:
{{{
#!CommitTicketReference repository=""
revision="231c595bde342e507091167387fba7ba1882b9c9"
[2.1.x] Refs #16470 -- Fixed typo in a FileResponse test.

Backport of ee52044a278885bd9455dd59b1e16c5d5e2d68ce from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/16470#comment:13>

Reply all
Reply to author
Forward
0 new messages