Some convenience routines for working with HTTP 1.1 (RFC2616). See https://datatracker.ietf.org/doc/html/rfc2616
Latest release 20260531:
- header(): new default=None optional parameter.
- content_length,content_type: plumb keyword arguments through to header().
- New content_encodings(headers) returning a list of the content encodings from headers.
Short summary:
content_encodings: A list of the encodings named in theContent-Encodingheader.content_length: Return the value of theContent-Lengthheader, orNone.content_type: Return the parsed value of theContent-Typeheader, orNone.datetime_from_asctime_date: 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: Parse an HTTP-date from a string, return a datetime object. See RFC2616 section 3.3.1.datetime_from_rfc1123_date: 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: 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.default_headerregistry: Return the defaultemail.headerregistry.HeaderRegistryinstance. Note that this is shared and should probably not be modified.get_lws: Gather up an LWS.get_quoted_string: Match a quoted-string insstarting atoffset.get_space: Gather up a sequence of SP or HT, possibly empty.get_text: Gather up a sequence of TEXT characters (possibly empty).get_token: Get an RFC2616 token from the stringsstarting atoffset. Return token, new_offset. See RFC2616 part 2.2.header: Return a header parsed into an instance ofemail.headerregistry.BaseHeaderordefaultifheader_nameis not present.message_has_body: 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: Parse the opening line of a chunked-encoding chunk.pass_chunked: Copy "chunked" data fromfpintofpout, and an optional trailer section (default False). See RFC2616, part 3.6.1.pass_length: Copy a specific amount of data fromfpintofpout.read_chunked: Generator that reads "chunked" data fromfpin, and an optional trailer section (default False). See RFC2616, part 3.6.1.read_headers: 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: Read HTTP Request-Line from the binary filefp, return method, uri, version. See RFC2616 section 5.1. If an empty request line is received return None, None, None.
Module contents:
-
content_encodings(headers: Mapping[str, str], **header_kw) -> List[str]: A list of the encodings named in theContent-Encodingheader. -
content_length(headers: Mapping[str, str], **header_kw) -> Optional[int]: Return the value of theContent-Lengthheader, orNone.Note that
headersis expected to be a case insensitive mapping. -
content_type(headers: Mapping[str, str], **header_kw) -> email.headerregistry.ContentTypeHeader: Return the parsed value of theContent-Typeheader, orNone.Note that
headersis 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_quoted_string(s, offset=0): Match a quoted-string insstarting atoffset. -
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 stringsstarting atoffset. Return token, new_offset. See RFC2616 part 2.2. -
header(headers: Mapping[str, str], header_name: str, registry: Optional[email.headerregistry.HeaderRegistry] = None, *, default=None) -> Optional[email.headerregistry.BaseHeader]: Return a header parsed into an instance ofemail.headerregistry.BaseHeaderordefaultifheader_nameis 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 fromfpintofpout, and an optional trailer section (default False). See RFC2616, part 3.6.1. -
pass_length(fpin, fpout, length): Copy a specific amount of data fromfpintofpout. -
read_chunked(fpin, has_trailer=False): Generator that reads "chunked" data fromfpin, 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 filefp, return method, uri, version. See RFC2616 section 5.1. If an empty request line is received return None, None, None.
Release Log
Release 20260531:
- header(): new default=None optional parameter.
- content_length,content_type: plumb keyword arguments through to header().
- New content_encodings(headers) returning a list of the content encodings from headers.
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 20260531
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cs_rfc2616-20260531.tar.gz | 5.6 kB | Without provenance | Details for cs_rfc2616-20260531.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cs_rfc2616-20260531-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for cs_rfc2616-20260531-py2.py3-none-any.whl |
Total release size: 12.2 kB
Release files / cs_rfc2616-20260531.tar.gz
| Download URL | cs_rfc2616-20260531.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b10f8bf8953c363773c8a0a0ab8336d17f1081b8d9ba98441347e6e9fe4090d
|
|
BLAKE2b-256 checksum How to use checksums |
6da34839d575c45a87eee7c523bbeceb58937fb55affbb82227968ff8cae97a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Release files / cs_rfc2616-20260531-py2.py3-none-any.whl
| Download URL | cs_rfc2616-20260531-py2.py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ee43ecfd782258cc5b34bf47681b348a48895f3b6c8c754419d4b7e4f087f208
|
|
BLAKE2b-256 checksum How to use checksums |
2096a75dace733decbc092b5ccbe2147a8d5c85d66e50b42ebacda85207bcff0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Security for cs-rfc2616 20260531
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.