--- id: httptools version: "0.8.0" license: MIT license_treatment: permissive maintenance: active --- # httptools — A collection of framework independent HTTP protocol utils. License: permissive · Maintenance: active · Popularity: top 1,000 on PyPI ## Install pip install httptools uv add httptools poetry add httptools ## Description ![Tests](https://github.com/MagicStack/httptools/workflows/Tests/badge.svg) httptools is a Python binding for the nodejs HTTP parser. The package is available on PyPI: `pip install httptools`. # APIs httptools contains two classes `httptools.HttpRequestParser`, `httptools.HttpResponseParser` (fulfilled through [llhttp](https://github.com/nodejs/llhttp)) and a function for parsing URLs `httptools.parse_url` (through [http-parse](https://github.com/nodejs/http-parser) for now). See unittests for examples. ```python class HttpRequestParser: def __init__(self, protocol): """HttpRequestParser protocol -- a Python object with the following methods (all optional): - on_message_begin() - on_url(url: bytes) - on_header(name: bytes, value: bytes) - on_headers_complete() - on_body(body: bytes) - on_message_complete() - on_chunk_header() - on_chunk_complete() - on_status(status: bytes) """ def get_http_version(self) -> str: """Return an HTTP protocol version.""" def should_keep_alive(self) -> bool: """Return ``True`` if... [View on SkillFed](https://skillfed.io/packages/httptools) · [View on PyPI](https://pypi.org/project/httptools/)