Skip to main content

Parse and generate Content-Disposition headers; Fork of rfc6266 with bugfixes.

Project description

rfc6266-parser

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.

difference rfc6266

This module is a fork of rfc6266 which includes the latest bugfix ‘NullHandler should be an instance, not a class’ and bumped the version to 0.0.5.

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.4, Python 3.5, Python 3.6 and PyPy (1.7), PyPy(5.10.0) for Python3.

https://secure.travis-ci.org/SWW13/python-rfc6266-parser.png

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rfc6266-parser-0.0.6.tar.gz (8.5 kB view details)

Uploaded Source

File details

Details for the file rfc6266-parser-0.0.6.tar.gz.

File metadata

  • Download URL: rfc6266-parser-0.0.6.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.8.0

File hashes

Hashes for rfc6266-parser-0.0.6.tar.gz
Algorithm Hash digest
SHA256 6eb7d7223c75727ac697d3150c3eea461e1660a9ca116bb29b57d751abeeec65
MD5 8f82ad9e9d28a3d0ec9a83ff08310a45
BLAKE2b-256 81cf1f4977bd110bb78c7ff1b8a6344bb0630e25ad42870099e56f9896a302cb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page