httplint
This Python library lints HTTP messages; it checks them for correctness and reports any issues it finds.
It has been extracted from REDbot, which will eventually depend upon it. Unlike REDbot, it does not perform any 'active' checks by making requests to the network, and it does not have a Web user interface.
Using httplint as a Library
httplint exposes two classes for linting: HttpRequestLinter and HttpResponseLinter. They expose the following methods for telling the linter about the HTTP message:
- As appropriate:
process_request_topline, which takes threebytesarguments:method,uri, andversionprocess_response_topline, which takes threebytesarguments:version,status_code, andstatus_phrase
process_headersfor the headers, taking a list of (name,value) tuples (bothbytes)feed_contentfor the body (which can be called zero to many times), taking aninbytesargumentfinish_contentwhen done, which has two arguments; aboolindicating whether the response was complete, and an optional list of tuples for the trailers, in the same format thatprocess_headerstakes.
For example:
from httplint import HttpResponseLinter
linter = HttpResponseLinter()
linter.process_response_topline(b'HTTP/1.1', b'200', b'OK')
linter.process_headers([
(b'Content-Type', b'text/plain'),
(b'Content-Length', b'10'),
(b'Cache-Control', b'max-age=60')
])
linter.feed_content(b'12345')
linter.feed_content(b'67890')
linter.finish_content(True)
Using httplint from the Command Line
httplint can also be used from the command line. For example:
> curl -s -i --raw https://www.mnot.net/ | httplint -n
* The Content-Length header is correct.
* The resource last changed 8 days 6 hr ago.
* This response allows all caches to store it.
* The server's clock is correct.
* This response is fresh until 3 hr from now.
* This response may still be served by a cache once it becomes stale.
Interpreting Notes
Once a message has been linted, the results will appear on the notes property. This is a list of Note objects, each having the following attributes:
category- the Note's category; seenote.categorieslevel- seenote.levelssummary- a brief, one-line description of the notedetail- a longer explanation
Note that summary is textual, and needs to be escaped in a markup environment; detail, however, is already escaped HTML.
Continuing our example:
for note in linter.notes:
print(note.summary)
and the output should be:
The Content-Length header is correct.
This response allows all caches to store it.
This response doesn't have a Date header.
This response is fresh until 1 min from now.
This response may still be served by a cache once it becomes stale.
Field Descriptions
The description of any field can be found by calling get_field_description. For example:
>>> from httplint import get_field_description
>>> get_field_description("Allow")
'The `Allow` response header advertises the set of methods that are supported by the resource.'
If a description cannot be found it will return None.
Metadata
Release files for httplint 2023.12.8
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 |
|---|---|---|---|---|
| httplint-2023.12.8.tar.gz | 70.8 kB | Without provenance | Details for httplint-2023.12.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| httplint-2023.12.8-py3-none-any.whl | Python 3 | none | any | Details for httplint-2023.12.8-py3-none-any.whl |
Total release size: 176.3 kB
Release files / httplint-2023.12.8.tar.gz
| Download URL | httplint-2023.12.8.tar.gz |
|---|---|
| Size | 70.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
887eb85be3b8818c695615f28195b1ed09f30c031d933306a434243aadfa32b1
|
|
BLAKE2b-256 checksum How to use checksums |
f327b5b2882d98c8e92bc0f5ed67252cb29215774afd3c3e22a17c75a190d13e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / httplint-2023.12.8-py3-none-any.whl
| Download URL | httplint-2023.12.8-py3-none-any.whl |
|---|---|
| Size | 105.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58d042bf22807a1f208b2cf06de737e5146daff336f3483d05de48f54b8262e9
|
|
BLAKE2b-256 checksum How to use checksums |
af8dc7beafe8379dbf68d7fde0652db012d670ab28ca939b2bf5a02b3f816be1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for httplint 2023.12.8
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.