
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
This Python library lints HTTP messages; it checks them for correctness and reports any issues it finds.
It performs all message-level checks for REDbot, but does not perform any 'active' checks by making requests to the network, and it does not have a Web user interface.
httplint exposes two classes for linting: HttpRequestLinter
and HttpResponseLinter
. They expose the following methods for telling the linter about the HTTP message:
process_request_topline
, which takes three bytes
arguments: method
, uri
, and version
process_response_topline
, which takes three bytes
arguments: version
, status_code
, and status_phrase
process_headers
for the headers, taking a list of (name
, value
) tuples (both bytes
)feed_content
for the body (which can be called zero to many times), taking an inbytes
argumentfinish_content
when done, which has two arguments; a bool
indicating whether the response was complete, and an optional list of tuples for the trailers, in the same format that process_headers
takes.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)
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.
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; see note.categories
level
- see note.levels
summary
- a brief, one-line description of the notedetail
- a longer explanationNote 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.
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
.
FAQs
Lint for HTTP messages.
We found that httplint demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.