RFC6266 implementation in Python
Project description
pyrfc6266
A python implementation of RFC 6266 meant to replace https://github.com/g2p/rfc6266 and its forks as they rely on LEPL.
This implementation relies on pyparsing which seems to continue to get updates.
Installation
pip install pyrfc6266
Usage
Parse a content-disposition header into its components:
>>> import pyrfc6266
>>> pyrfc6266.parse('attachment; filename="foo.html"')
('attachment', [ContentDisposition(name='filename', value='foo.html')])
Parse a header into a useful filename:
>>> import pyrfc6266
>>> pyrfc6266.parse_filename('attachment; filename="foo.html"')
'foo.html'
Turn a requests response into a filename:
>>> import requests
>>> import pyrfc6266
>>> response = requests.get('http://httpbin.org/response-headers?Content-Disposition=attachment;%20filename%3d%22foo.html%22')
>>> pyrfc6266.requests_response_to_filename(response)
'foo.html'
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyrfc6266-1.0.1.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for pyrfc6266-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cf8d6d65301f4d1a485dbd644c9d6d2cb33e3f18ee79370cfbbcf3d9e0ab76e |
|
MD5 | a486f3b76711b12ecf22dd0c985a91ab |
|
BLAKE2b-256 | 665eb62e052d530c4e8bca2cbda6a51bb84901f9946d7239f0d5809a817f7081 |