Skip to content
/ rfc6266 Public

Content-Disposition header support for Python

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING
Notifications You must be signed in to change notification settings

g2p/rfc6266

Folders and files

NameName
Last commit message
Last commit date

Latest commit

cad5896 · Nov 18, 2013

History

54 Commits
Apr 8, 2012
Nov 13, 2013
Feb 1, 2012
Feb 1, 2012
Oct 22, 2012
Feb 1, 2012
Nov 18, 2013
Nov 13, 2013
Nov 13, 2013
Nov 13, 2013

Repository files navigation

rfc6266

This module parses and generates HTTP Content-Disposition headers. These headers are used when getting resources for download; they provide a hint of whether the file should be downloaded, and of what filename to use when saving.

Usage

Receiver

parse_headers builds a ContentDisposition object from the Content-Disposition header and (as a fallback) the document location. Shortcuts work with response objects from httplib2 and the requests library.

Important attributes of ContentDisposition are is_inline, filename_unsafe, filename_sanitized.

Sender

build_header builds a header value from a filename.

Security

The Content-Disposition filename should be used with caution. Do not let the sender overwrite an arbitrary filesystem location, pick arbitrary extensions or filenames with special meaning, pick filenames containing unusual or misleading characters, etc. Read RFC 6266 section 4.3 for more details.

Testing

To test in the current Python implementation:

py.test

To test compatibility across Python releases:

tox

rfc6266 is currently tested under Python 2.7, Python 2.6, Python 3.3, Python 3.2, and PyPy (1.7).

https://secure.travis-ci.org/g2p/rfc6266.png

References