Skip to main content

No project description provided

Project description

Fast Header

HTTP Header Encoder & Decoder for Python

Install

pip install fast-header

Usage

cache control

from fast_header import CacheControl

cc = CacheControl(max_stale=True)
assert cc.max_stale
assert str(cc) == "max_stable"
cc = CacheControl.parse("max_stable")

etag

from fast_header import ETag
setag = ETag(value="a") # strong etag
wetag = ETag(value="a", weak=True) # weak etag

Content Disposition

from fast_header import ContentDisposition
cd = ContentDisposition.parse('attachment; filename="=?ISO-8859-1?Q?foo-=E4.html?="')
assert cd.type == 'attachment'
assert cd.parameters == { 'filename': '=?ISO-8859-1?Q?foo-=E4.html?=' }

Content Type

from fast_header import ContentType
cd = ContentType.parse('text/html; charset=utf-8; foo=bar')
assert cd.type == 'text/html'
assert cd.parameters == { 'charset': 'utf-8', 'foo': 'bar' }

Content Range

from fast_header import ContentRange

from fast_header import ContentRange
cr = ContentRange.parse("bytes 0-20/30")
assert cr.unit == "bytes"
assert cr.range is not None
assert cr.range.start == 0
assert cr.range.stop == 20
assert cr.size == 30

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

fast_header-0.1.3.tar.gz (6.8 kB view hashes)

Uploaded Source

Built Distribution

fast_header-0.1.3-py3-none-any.whl (9.2 kB view hashes)

Uploaded Python 3

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