Skip to main content

Some convenience routines for working with HTTP 1.1 (RFC2616). See https://datatracker.ietf.org/doc/html/rfc2616

Latest release 20250306: New default_headerregistry(), header(headers,name), content_length(headers) and content_type(headers).

content_length(headers: Mapping[str, str]) -> Optional[int]

Return the value of the Content-Length header, or None.

Note that headers is expected to be a case insensitive mapping.

content_type(headers: Mapping[str, str]) -> email.headerregistry.ContentTypeHeader

Return the parsed value of the Content-Type header, or None.

Note that headers is expected to be a case insensitive mapping.

datetime_from_asctime_date(s)

Parse an asctime-date from a string, return a datetime object. See RFC2616 section 3.3.1. Format: wkday, mon d hh:mm:ss yyyy

datetime_from_http_date(s)

Parse an HTTP-date from a string, return a datetime object. See RFC2616 section 3.3.1.

datetime_from_rfc1123_date(s)

Parse an rfc1123-date from a string, return a datetime object. See RFC2616 section 3.3.1. Format: wkday, dd mon yyyy hh:mm:ss GMT

datetime_from_rfc850_date(s)

Parse an rfc850-date from a string, return a datetime object. See RFC2616 section 3.3.1. Format: weekday, dd-mon-yy hh:mm:ss GMT

enc8(s)

encode and decode bytes<->str for HTTP stream: 8-bit 1-to-1

get_lws(s, offset=0)

Gather up an LWS.

get_quoted_string(s, offset=0)

Match a quoted-string in s starting at offset.

get_space(s, offset=0)

Gather up a sequence of SP or HT, possibly empty.

get_text(s, offset=0)

Gather up a sequence of TEXT characters (possibly empty).

get_token(s, offset=0)

Get an RFC2616 token from the string s starting at offset. Return token, new_offset. See RFC2616 part 2.2.

header(headers: Mapping[str, str], header_name: str, registry: Optional[email.headerregistry.HeaderRegistry] = None) -> Optional[email.headerregistry.BaseHeader]

Return a header parsed into an instance of email.headerregistry.BaseHeader or None if header_name is not present.

message_has_body(headers)

Does this message have a message body to forward? See RFC2616, part 4.3 and 4.4. Note that HTTP certain requests preempty this; for example HEAD never has a body. That aspect is not considered here.

parse_chunk_line1(bline)

Parse the opening line of a chunked-encoding chunk.

pass_chunked(fpin, fpout, has_trailer)

Copy "chunked" data from fpin to fpout, and an optional trailer section (default False). See RFC2616, part 3.6.1.

pass_length(fpin, fpout, length)

Copy a specific amount of data from fpin to fpout.

read_chunked(fpin, has_trailer=False)

Generator that reads "chunked" data from fpin, and an optional trailer section (default False). See RFC2616, part 3.6.1.

read_headers(fp)

Read headers from a binary file such as an HTTP stream, return the raw binary data and the corresponding Message object.

read_http_request_line(fp)

Read HTTP Request-Line from the binary file fp, return method, uri, version. See RFC2616 section 5.1. If an empty request line is received return None, None, None.

Release Log

Release 20250306: New default_headerregistry(), header(headers,name), content_length(headers) and content_type(headers).

Release 20160828: Use "install_requires" instead of "requires" in DISTINFO.

Release 20160827: Initial PyPI release.

Metadata

Release files for cs-rfc2616 20250306

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cs-rfc2616 20250306
File Size Uploaded
cs_rfc2616-20250306.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cs-rfc2616 20250306
File Interpreter ABI Platform
cs_rfc2616-20250306-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 11.0 kB

Release files / cs_rfc2616-20250306.tar.gz

Download URL cs_rfc2616-20250306.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9e8d4466f50242fbb630e629120843dfdf4b20b9bb558a56d6b3ba14564df53b
BLAKE2b-256 checksum
How to use checksums
fad8debae76e1bff9c50101f88b9ae7754da98860b73c8ba36f0b27f8bfab337
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Release files / cs_rfc2616-20250306-py2.py3-none-any.whl

Download URL cs_rfc2616-20250306-py2.py3-none-any.whl
Size 6.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
0c159758b2b22e33ee226cd54fcdc10a92adb66eee641943b5eccc84199c527b
BLAKE2b-256 checksum
How to use checksums
0e346794ac7316be9b2f3669bf2c8b9774314a4040dc8e57ac939e6783e137a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

20250306 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page