Skip to content
 
 

Repository files navigation

pyrfc6266

Tests

Note: This package is a fork of JohnDoee/pyrfc6266, which is no longer maintained. The original README.

A python implementation of RFC 6266 meant to replace g2p/rfc6266 as it relies on LEPL.

This implementation relies on pyparsing.

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

About

Implementation of content-disposition header parsing without LEPL (rfc6266)

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages