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) and a function for
parsing URLs httptools.parse_url (through
http-parse for now).
See unittests for examples.
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 keep-alive mode is preferred."""
def should_upgrade(self) -> bool:
"""Return ``True`` if the parsed request is a valid Upgrade request.
The method exposes a flag set just before on_headers_complete.
Calling this method earlier will only yield `False`.
"""
def feed_data(self, data: bytes):
"""Feed data to the parser.
Will eventually trigger callbacks on the ``protocol``
object.
On HTTP upgrade, this method will raise an
``HttpParserUpgrade`` exception, with its sole argument
set to the offset of the non-HTTP data in ``data``.
"""
def get_method(self) -> bytes:
"""Return HTTP request method (GET, HEAD, etc)"""
class HttpResponseParser:
"""Has all methods except ``get_method()`` that
HttpRequestParser has."""
def get_status_code(self) -> int:
"""Return the status code of the HTTP response"""
def parse_url(url: bytes):
"""Parse URL strings into a structured Python object.
Returns an instance of ``httptools.URL`` class with the
following attributes:
- schema: bytes
- host: bytes
- port: int
- path: bytes
- query: bytes
- fragment: bytes
- userinfo: bytes
"""
Development
-
Clone this repository with
git clone --recursive git@github.com:MagicStack/httptools.git -
Create a virtual environment with Python 3.5:
python3.5 -m venv envname -
Activate the environment with
source envname/bin/activate -
Install Cython with
pip install cython -
Run
makeandmake test.
License
MIT.
Metadata
Release files for httptools 0.2.0
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 |
|---|---|---|---|---|
| httptools-0.2.0.tar.gz | 169.3 kB | Without provenance | Details for httptools-0.2.0.tar.gz |
Built distributions (wheels)
Total release size: 3.2 MB
Release files / httptools-0.2.0.tar.gz
| Download URL | httptools-0.2.0.tar.gz |
|---|---|
| Size | 169.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
94505026be56652d7a530ab03d89474dc6021019d6b8682281977163b3471ea0
|
|
BLAKE2b-256 checksum How to use checksums |
968208c5ee0191ea7f765e9a44cc66827c0ba35b896f72b4d31f9cd9d180b08f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp39-cp39-win_amd64.whl
| Download URL | httptools-0.2.0-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 141.3 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
200fc1cdf733a9ff554c0bb97a4047785cfaad9875307d6087001db3eb2b417f
|
|
BLAKE2b-256 checksum How to use checksums |
d4cbc15e64f204d748533c197434afa325e48766b7045de2e4b15af198ba2338
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp39-cp39-manylinux1_x86_64.whl
| Download URL | httptools-0.2.0-cp39-cp39-manylinux1_x86_64.whl |
|---|---|
| Size | 343.2 kB |
| Tags | CPython 3.9 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
fd3b8905e21431ad306eeaf56644a68fdd621bf8f3097eff54d0f6bdf7262065
|
|
BLAKE2b-256 checksum How to use checksums |
100a95cacee1b444993a1c2106b4fdb890ea3a648918f7cb8744a6cd1f9591db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp39-cp39-macosx_10_14_x86_64.whl
| Download URL | httptools-0.2.0-cp39-cp39-macosx_10_14_x86_64.whl |
|---|---|
| Size | 156.2 kB |
| Tags | CPython 3.9 macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
b08d00d889a118f68f37f3c43e359aab24ee29eb2e3fe96d64c6a2ba8b9d6557
|
|
BLAKE2b-256 checksum How to use checksums |
564724d1d1116ff514ecaf1f4e6f832856375df567d59191acb593ac8f818c48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp38-cp38-win_amd64.whl
| Download URL | httptools-0.2.0-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 141.2 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
cc9be041e428c10f8b6ab358c6b393648f9457094e1dcc11b4906026d43cd380
|
|
BLAKE2b-256 checksum How to use checksums |
2a4285763f28626b613b470442987eccd461f3308485b1d9c528499d683b2979
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp38-cp38-manylinux1_x86_64.whl
| Download URL | httptools-0.2.0-cp38-cp38-manylinux1_x86_64.whl |
|---|---|
| Size | 354.8 kB |
| Tags | CPython 3.8 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
813871f961edea6cb2fe312f2d9b27d12a51ba92545380126f80d0de1917ea15
|
|
BLAKE2b-256 checksum How to use checksums |
b3e7b893f9e994732e8763d8f59913cb70faaa44f41df2fa15fa1624827d8f2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp38-cp38-macosx_10_14_x86_64.whl
| Download URL | httptools-0.2.0-cp38-cp38-macosx_10_14_x86_64.whl |
|---|---|
| Size | 155.5 kB |
| Tags | CPython 3.8 macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
a289c27ccae399a70eacf32df9a44059ca2ba4ac444604b00a19a6c1f0809943
|
|
BLAKE2b-256 checksum How to use checksums |
03d15d617f1ca8d7839963db6c30e47f5c2276a99c44ee2c2535dcbe1ffcde4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp37-cp37m-win_amd64.whl
| Download URL | httptools-0.2.0-cp37-cp37m-win_amd64.whl |
|---|---|
| Size | 139.8 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d5682eeb10cca0606c4a8286a3391d4c3c5a36f0c448e71b8bd05be4e1694bfb
|
|
BLAKE2b-256 checksum How to use checksums |
415a89c0f669ae9a58e6855590a0f5c0af0f37a6bea57b51b0f79b6911c0dfcb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp37-cp37m-manylinux1_x86_64.whl
| Download URL | httptools-0.2.0-cp37-cp37m-manylinux1_x86_64.whl |
|---|---|
| Size | 344.6 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
80ffa04fe8c8dfacf6e4cef8277347d35b0442c581f5814f3b0cf41b65c43c6e
|
|
BLAKE2b-256 checksum How to use checksums |
4c87ebb92639705924aac5ed6aa91bd4332b20d7180f3e94bd168742e7671025
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp37-cp37m-macosx_10_14_x86_64.whl
| Download URL | httptools-0.2.0-cp37-cp37m-macosx_10_14_x86_64.whl |
|---|---|
| Size | 154.1 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
01b392a166adcc8bc2f526a939a8aabf89fe079243e1543fd0e7dc1b58d737cb
|
|
BLAKE2b-256 checksum How to use checksums |
d20517556eb2088d280cd3fe78e52e334cf24d052cdb27102e87eee5233fef80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp36-cp36m-win_amd64.whl
| Download URL | httptools-0.2.0-cp36-cp36m-win_amd64.whl |
|---|---|
| Size | 139.5 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a7594f9a010cdf1e16a58b3bf26c9da39bbf663e3b8d46d39176999d71816658
|
|
BLAKE2b-256 checksum How to use checksums |
9489e88f473d8b9b0e60c9e3693fe16e4c8ef8aec67f4228e1a65e8dc6c2eb97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp36-cp36m-manylinux1_x86_64.whl
| Download URL | httptools-0.2.0-cp36-cp36m-manylinux1_x86_64.whl |
|---|---|
| Size | 343.6 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
3ab1f390d8867f74b3b5ee2a7ecc9b8d7f53750bd45714bf1cb72a953d7dfa77
|
|
BLAKE2b-256 checksum How to use checksums |
818fa8238a287d1bd3455e4297a358d4cdbd1da2bfb0ec3fbfb8a254119aa8e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp36-cp36m-macosx_10_14_x86_64.whl
| Download URL | httptools-0.2.0-cp36-cp36m-macosx_10_14_x86_64.whl |
|---|---|
| Size | 154.8 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
a23166e5ae2775709cf4f7ad4c2048755ebfb272767d244e1a96d55ac775cca7
|
|
BLAKE2b-256 checksum How to use checksums |
25d0092d6d1541a37885dbf11525ca9ad2a7082714511256801961d495b529c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp35-cp35m-manylinux1_x86_64.whl
| Download URL | httptools-0.2.0-cp35-cp35m-manylinux1_x86_64.whl |
|---|---|
| Size | 339.2 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
78d03dd39b09c99ec917d50189e6743adbfd18c15d5944392d2eabda688bf149
|
|
BLAKE2b-256 checksum How to use checksums |
aea50b450216fe120f2f92996e4c7632d8db65d1fdc574c98cfb7adb6148cc1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / httptools-0.2.0-cp35-cp35m-macosx_10_14_x86_64.whl
| Download URL | httptools-0.2.0-cp35-cp35m-macosx_10_14_x86_64.whl |
|---|---|
| Size | 153.0 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
79dbc21f3612a78b28384e989b21872e2e3cf3968532601544696e4ed0007ce5
|
|
BLAKE2b-256 checksum How to use checksums |
8e4c4d22571b5f8eba7eff92c09e46b0d360f7813c3408bc68fcdbd60d1b6e6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Security for httptools 0.2.0
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.