ppc64le/linux/: httptools-0.6.4 metadata and description

Homepage Simple index

A collection of framework independent HTTP protocol utils.

author Yury Selivanov
author_email [email protected]
classifiers
  • License :: OSI Approved :: MIT License
  • Intended Audience :: Developers
  • Programming Language :: Python :: 3
  • Operating System :: POSIX
  • Operating System :: MacOS :: MacOS X
  • Environment :: Web Environment
  • Development Status :: 5 - Production/Stable
  • Environment :: MetaData :: IBM Python Ecosystem
description_content_type text/markdown
dynamic summary
license MIT
license_file LICENSE
provides_extras test
requires_dist
  • Cython>=0.29.24; extra == "test"
requires_python >=3.8.0
File Tox results History
httptools-0.6.4-cp310-cp310-linux_ppc64le.whl
Size
429 KB
Type
Python Wheel
Python
3.10
httptools-0.6.4-cp311-cp311-linux_ppc64le.whl
Size
447 KB
Type
Python Wheel
Python
3.11
httptools-0.6.4-cp312-cp312-linux_ppc64le.whl
Size
507 KB
Type
Python Wheel
Python
3.12
httptools-0.6.4-cp313-cp313-linux_ppc64le.whl
Size
461 KB
Type
Python Wheel
Python
3.13
httptools-0.6.4-cp39-cp39-linux_ppc64le.whl
Size
438 KB
Type
Python Wheel
Python
3.9

Tests

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

  1. Clone this repository with git clone --recursive [email protected]:MagicStack/httptools.git

  2. Create a virtual environment with Python 3: python3 -m venv envname

  3. Activate the environment with source envname/bin/activate

  4. Install development requirements with pip install -e .[test]

  5. Run make and make test.

License

MIT.

Export Classification Notice

The software hosted on this website consists of publicly available open‑source packages. To the extent U.S. export regulations apply, software that is publicly available as described in 15 C.F.R. §§ 734.7 (for non-encryption software) or 742.15(b) (for encryption software) is not subject to the Export Administration Regulations (EAR). Users are responsible for complying with all applicable export laws and regulations.