Skip to main content

Reusable client middlewares for aiohttp

Project description

GitHub Actions CI status codecov.io status Latest PyPI package version Supported Python versions Latest Read The Docs

Reusable client middlewares for aiohttp.

aiohttp-client-middlewares is a small, pure-Python collection of ready-to-use client middlewares for aiohttp. It currently provides DigestAuthMiddleware, vendored from aiohttp core; this package is the canonical home for it going forward.

Middlewares plug into aiohttp.ClientSession through the client middleware API introduced in aiohttp 3.12, so they can wrap every outgoing request without subclassing the session.

Installation

$ pip install aiohttp-client-middlewares

This requires aiohttp >= 3.12 (the first release with the client-middleware API and DigestAuthMiddleware) and yarl >= 1.17.0. Both are pulled in automatically.

Supported Python versions: 3.10, 3.11, 3.12, 3.13 and 3.14.

Quickstart

Pass one or more middlewares to aiohttp.ClientSession via the middlewares argument. DigestAuthMiddleware transparently performs the HTTP Digest authentication handshake for every request made with the session:

import asyncio

import aiohttp
from aiohttp_client_middlewares import DigestAuthMiddleware


async def main() -> None:
    digest = DigestAuthMiddleware("user", "pass")
    async with aiohttp.ClientSession(middlewares=(digest,)) as session:
        async with session.get("https://httpbin.org/digest-auth/auth/user/pass") as resp:
            print("Status:", resp.status)
            print("Body:", await resp.json())


asyncio.run(main())

Documentation

https://aiohttp-client-middlewares.readthedocs.io/

Communication channels

aio-libs Discussions: https://github.com/aio-libs/aiohttp-client-middlewares/discussions

Matrix: #aio-libs:matrix.org

License

aiohttp-client-middlewares is offered under the Apache-2.0 license. See the LICENSE file for the full text.

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

aiohttp_client_middlewares-0.1.0.tar.gz (34.7 kB view details)

Uploaded Source

Built Distribution

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

aiohttp_client_middlewares-0.1.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file aiohttp_client_middlewares-0.1.0.tar.gz.

File metadata

File hashes

Hashes for aiohttp_client_middlewares-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15563b0a81ecca4eec8e0744841635437c542f8729598ab51a68ddc03c904e7b
MD5 00938ac466be27b2cb81686829d29f6b
BLAKE2b-256 40554836c52f03c6e3b6d8445b0a18ea94114a4c11c3b485d1c9303865e5ba99

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiohttp_client_middlewares-0.1.0.tar.gz:

Publisher: ci-cd.yml on aio-libs/aiohttp-client-middlewares

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

File details

Details for the file aiohttp_client_middlewares-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiohttp_client_middlewares-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51657db1eac7a23feb0d4fc609b95b66471488328bba2e9e1700fa0674240b6c
MD5 27add06826df80dd6d153d204f8e9339
BLAKE2b-256 c8ae5560d224900c6cb10258e0f2e08ab4e2434026f042a7916f082cbc89ee60

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiohttp_client_middlewares-0.1.0-py3-none-any.whl:

Publisher: ci-cd.yml on aio-libs/aiohttp-client-middlewares

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