diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 75b05ca..036efc8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,9 +37,9 @@ jobs: mkdir -p dist/ echo "${VERSION}" > dist/VERSION - - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: - name: dist + name: dist-version path: dist/ build-sdist: @@ -47,22 +47,22 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 with: fetch-depth: 50 submodules: true - name: Set up Python - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 + uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 - name: Build source distribution run: | python -m pip install -U setuptools wheel pip python setup.py sdist - - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: - name: dist + name: dist-sdist path: dist/*.tar.* build-wheels: @@ -73,19 +73,17 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] cibw_arch: ["auto64", "aarch64", "universal2"] cibw_python: - - "cp38-*" - - "cp39-*" - - "cp310-*" - - "cp311-*" - - "cp312-*" + - "cp38" + - "cp39" + - "cp310" + - "cp311" + - "cp312" + - "cp313" exclude: - os: ubuntu-latest cibw_arch: universal2 - os: macos-latest cibw_arch: aarch64 - - os: macos-latest - cibw_python: "cp37-*" - cibw_arch: universal2 - os: windows-latest cibw_arch: universal2 - os: windows-latest @@ -99,30 +97,30 @@ jobs: PIP_DISABLE_PIP_VERSION_CHECK: 1 steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 with: fetch-depth: 50 submodules: true - name: Set up QEMU if: matrix.os == 'ubuntu-latest' && matrix.cibw_arch == 'aarch64' - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 with: platforms: arm64 - - uses: pypa/cibuildwheel@fff9ec32ed25a9c576750c91e06b410ed0c15db7 # v2.16.2 + - uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3 env: CIBW_BUILD_VERBOSITY: 1 - CIBW_BUILD: ${{ matrix.cibw_python }} + CIBW_BUILD: ${{ matrix.cibw_python }}-* CIBW_ARCHS: ${{ matrix.cibw_arch }} CIBW_TEST_EXTRAS: "test" CIBW_TEST_COMMAND: "python {project}/tests/__init__.py" CIBW_TEST_COMMAND_WINDOWS: "python {project}\\tests\\__init__.py" CIBW_TEST_SKIP: "*universal2:arm64" - - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: - name: dist + name: dist-${{ matrix.os }}-${{ matrix.cibw_arch }}-${{ matrix.cibw_python }} path: wheelhouse/*.whl publish: @@ -130,14 +128,15 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 with: fetch-depth: 5 submodules: false - - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: - name: dist + pattern: dist-* + merge-multiple: true path: dist/ - name: Extract Release Version @@ -171,7 +170,7 @@ jobs: ls -al dist/ - name: Upload to PyPI - uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e # v1.8.10 + uses: pypa/gh-action-pypi-publish@f7600683efdcb7656dec5b29656edb7bc586e597 # v1.10.3 with: user: __token__ password: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1c415c2..7c85de3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,14 +14,14 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] os: [windows-latest, ubuntu-latest, macos-latest] env: PIP_DISABLE_PIP_VERSION_CHECK: 1 steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 with: fetch-depth: 50 submodules: true @@ -37,7 +37,7 @@ jobs: __version__\s*=\s*(?:['"])([[:PEP440:]])(?:['"]) - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 + uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 if: steps.release.outputs.version == 0 with: python-version: ${{ matrix.python-version }} diff --git a/httptools/_version.py b/httptools/_version.py index 51078cc..c1c278c 100644 --- a/httptools/_version.py +++ b/httptools/_version.py @@ -10,4 +10,4 @@ # supported platforms, publish the packages on PyPI, merge the PR # to the target branch, create a Git tag pointing to the commit. -__version__ = '0.6.1' +__version__ = '0.6.2' diff --git a/httptools/parser/parser.pyi b/httptools/parser/parser.pyi index 83fe34b..8a714bf 100644 --- a/httptools/parser/parser.pyi +++ b/httptools/parser/parser.pyi @@ -1,11 +1,9 @@ from typing import Union, Any -from array import array +from array import array from .protocol import HTTPProtocol - - class HttpParser: - def __init__(self, protocol:Union[HTTPProtocol, Any]) -> None: + def __init__(self, protocol: Union[HTTPProtocol, Any]) -> None: """ protocol -- a Python object with the following methods (all optional): @@ -24,15 +22,18 @@ class HttpParser: 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`.""" + The method exposes a flag set just before on_headers_complete. + Calling this method earlier will only yield `False`.""" ... - def feed_data(self, data:Union[bytes, bytearray, memoryview, array]) -> None: + + def feed_data(self, data: Union[bytes, bytearray, memoryview, array]) -> None: """Feed data to the parser. Will eventually trigger callbacks on the ``protocol`` @@ -43,14 +44,12 @@ class HttpParser: set to the offset of the non-HTTP data in ``data``. """ - class HttpRequestParser(HttpParser): """Used for parsing http requests from the server's side""" - + def get_method(self) -> bytes: """Return HTTP request method (GET, HEAD, etc)""" - class HttpResponseParser(HttpParser): """Used for parsing http requests from the client's side""" diff --git a/httptools/parser/protocol.py b/httptools/parser/protocol.py index 5090f5c..c3b4234 100644 --- a/httptools/parser/protocol.py +++ b/httptools/parser/protocol.py @@ -1,15 +1,15 @@ from typing import Protocol + class HTTPProtocol(Protocol): """Used for providing static type-checking when parsing through the http protocol""" - def on_message_begin() -> None:... - def on_url(url: bytes) -> None:... - def on_header(name: bytes, value: bytes) -> None:... - def on_headers_complete() -> None:... - def on_body(body: bytes) -> None:... - def on_message_complete() -> None:... - def on_chunk_header() -> None:... - def on_chunk_complete() -> None:... - def on_status(status: bytes) -> None:... - + def on_message_begin() -> None: ... + def on_url(url: bytes) -> None: ... + def on_header(name: bytes, value: bytes) -> None: ... + def on_headers_complete() -> None: ... + def on_body(body: bytes) -> None: ... + def on_message_complete() -> None: ... + def on_chunk_header() -> None: ... + def on_chunk_complete() -> None: ... + def on_status(status: bytes) -> None: ... diff --git a/httptools/parser/url_parser.pyi b/httptools/parser/url_parser.pyi index b74ba74..f3d3488 100644 --- a/httptools/parser/url_parser.pyi +++ b/httptools/parser/url_parser.pyi @@ -2,15 +2,15 @@ from typing import Union from array import array class URL: - schema:bytes - host:bytes - port:int - path:bytes - query:bytes - fragment:bytes - userinfo:bytes + schema: bytes + host: bytes + port: int + path: bytes + query: bytes + fragment: bytes + userinfo: bytes -def parse_url(url:Union[bytes, bytearray, memoryview, array]) -> URL: +def parse_url(url: Union[bytes, bytearray, memoryview, array]) -> URL: """Parse URL strings into a structured Python object. Returns an instance of ``httptools.URL`` class with the @@ -25,5 +25,3 @@ def parse_url(url:Union[bytes, bytearray, memoryview, array]) -> URL: - userinfo: bytes """ ... - - diff --git a/setup.py b/setup.py index 200e6f6..adca1f8 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ ROOT = pathlib.Path(__file__).parent -CYTHON_DEPENDENCY = 'Cython(>=0.29.24,<0.30.0)' +CYTHON_DEPENDENCY = 'Cython>=0.29.24' class httptools_build_ext(build_ext):