Skip to main content

Lint for HTTP messages.

Project description

httplint

This Python library lints HTTP messages; it checks them for correctness and reports any issues it finds. httplint can report on 237 different aspects of your HTTP message, including checks against 164 header fields.

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.

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 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 argument
  • finish_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)

You can also enable no_content mode if you do not have the message body, or do not wish to check it:

linter = HttpResponseLinter(no_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; see note.categories
  • level - see note.levels
  • summary - a brief, one-line description of the note
  • detail - a longer explanation
  • subnotes - a list of child Note objects

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.

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

httplint-2026.4.3.tar.gz (611.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

httplint-2026.4.3-py3-none-any.whl (682.7 kB view details)

Uploaded Python 3

File details

Details for the file httplint-2026.4.3.tar.gz.

File metadata

  • Download URL: httplint-2026.4.3.tar.gz
  • Upload date:
  • Size: 611.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for httplint-2026.4.3.tar.gz
Algorithm Hash digest
SHA256 ad30dc8da48e9e42760f7168d1badcbf79036f5723fadbb3636cbd969360a45e
MD5 7a40261e7ddd450380835ef962fa4c7c
BLAKE2b-256 ab23c3b98c29a6a296fd335beaa581386a19716f16b7c6459d602120bdf7a49d

See more details on using hashes here.

Provenance

The following attestation bundles were made for httplint-2026.4.3.tar.gz:

Publisher: publish.yml on mnot/httplint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file httplint-2026.4.3-py3-none-any.whl.

File metadata

  • Download URL: httplint-2026.4.3-py3-none-any.whl
  • Upload date:
  • Size: 682.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for httplint-2026.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ed62fe8f9258221126d53447a26847deb79237bbc5f3a36bcbf19dde5da2bc0b
MD5 0c7852a558e445466e564155ec4fe0e0
BLAKE2b-256 4976bd35b7434d8b9ad172240dfda1a9e8af7d7d6d7edd92bd757cd0dbcfdce0

See more details on using hashes here.

Provenance

The following attestation bundles were made for httplint-2026.4.3-py3-none-any.whl:

Publisher: publish.yml on mnot/httplint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page