mini-aiohttp
mini-aiohttp 0.2.0 is a lightweight asynchronous HTTP/1.1 client and server built on Python's standard library and asyncio. It has no mandatory runtime dependencies and supports Python 3.9+.
Features
HTTP client
- Async HTTP/1.1 requests with keep-alive connection pooling and per-host concurrency limits.
- Redirect handling with cross-origin credential stripping.
- Bounded retries for idempotent methods only; streaming request bodies are never replayed.
- Cookie jar with host/domain, path and Secure matching.
- Streaming response downloads and async-iterable uploads using chunked transfer encoding.
- Multipart form and file uploads.
- HTTP and SOCKS5/SOCKS5h proxy support for HTTP targets.
- DNS cache, configurable timeouts, TLS context, request/response hooks.
- Bounded response sizes.
HTTP server
- Async routing, path parameters and middleware on successful, error and static-file responses.
- HTTP/1.1 keep-alive, bounded request bodies and chunked request decoding.
- HTTPS via a caller-provided ssl.SSLContext.
- Static file serving with resolved-path traversal protection and size limits.
- Chunked streaming responses using Response.stream().
- Graceful shutdown and connection caps.
- Lightweight runtime counters through Server.stats.
Security
- Header validation and request framing checks.
- CORS, security headers, token-bucket rate limiting and IP/CIDR policy middleware.
- Secure cookie helper and JSON request validation.
- Safe redirect behavior and bounded parsing.
Installation
pip install mini-aiohttp
pip install "mini-aiohttp[test]" # test extras when installing from source
Quick start
import asyncio
from mini_aiohttp import ClientSession, Response, Server
app = Server()
@app.route("/")
async def index(req):
return Response.json({"message": "hello"})
@app.route("/echo", method="POST")
async def echo(req):
return Response(200, req.body)
async def main():
await app.start("127.0.0.1", 8080)
try:
async with ClientSession() as session:
response = await session.get("http://127.0.0.1:8080/")
print(response.status, response.json())
finally:
await app.close()
asyncio.run(main())
Streaming response (including SSE)
import asyncio
from mini_aiohttp import Response, Server
app = Server()
@app.route("/events")
async def events(req):
async def generate():
for number in range(3):
yield f"data: {number}\n\n"
await asyncio.sleep(1)
return Response.stream(
generate(),
headers={"Content-Type": "text/event-stream", "Cache-Control": "no-cache"},
)
asyncio.run(app.serve_forever("127.0.0.1", 8080))
The server sends streamed bodies as HTTP/1.1 chunked transfer encoding. If the producer raises after response headers have been sent, the connection is closed; an HTTP error response can no longer be substituted at that point.
Client streaming
async def upload_chunks():
yield b"part one"
yield b"part two"
async with ClientSession() as session:
response = await session.post(
"http://127.0.0.1:8080/echo",
data=upload_chunks(),
)
print(response.status)
Runtime stats
print(app.stats)
# {
# "active_connections": 0,
# "total_connections": 1,
# "total_requests": 2,
# "status_counts": {200: 1, 404: 1},
# "uptime_requests_per_connection": 2.0
# }
Counters are process-local snapshots, not a distributed metrics backend. They do not expose CPU or memory usage.
Testing and building
python -m pip install -e ".[test]"
python -m pytest -v
python -m pip install build twine
python -m build
python -m twine check dist/*
GitHub Actions runs the test suite on Python 3.9, 3.10, 3.11, 3.12 and 3.13, and checks source/wheel distributions.
Current protocol boundaries
- HTTP/1.1 only; HTTP/2 and HTTP/3 are not implemented.
- WebSockets are not implemented.
- HTTPS through HTTP/SOCKS proxies is not implemented.
- SOCKS proxy support is for HTTP targets; use a direct TLS connection for HTTPS.
- Streaming responses require an async iterable.
- No automatic multi-process worker manager is included. reuse_port=True can be used where supported.
- Performance depends on OS limits, hardware, network conditions and application handlers. Run benchmarks on the target deployment; no fixed connection/throughput guarantee is made.
License
MIT
Metadata
Release files for mini-aiohttp 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 |
|---|---|---|---|---|
| mini_aiohttp-0.2.0.tar.gz | 35.5 kB | With provenance | Details for mini_aiohttp-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mini_aiohttp-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for mini_aiohttp-0.2.0-py3-none-any.whl |
Total release size: 63.5 kB
Release files / mini_aiohttp-0.2.0.tar.gz
| Download URL | mini_aiohttp-0.2.0.tar.gz |
|---|---|
| Size | 35.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1ab0c675eaef61925e7d79db65a30deae9ab07682cb9a9f01f4388a9540f610
|
|
BLAKE2b-256 checksum How to use checksums |
553aeca85cfa14227fe650adedda913cc1e43722f6818fbb4105da936dfb596c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / mini_aiohttp-0.2.0-py3-none-any.whl
| Download URL | mini_aiohttp-0.2.0-py3-none-any.whl |
|---|---|
| Size | 28.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
271c930ecd7e6424d7440e17dd60045044818ec56f6790e444e8846b455af714
|
|
BLAKE2b-256 checksum How to use checksums |
313ffc17e7e926a29ba7eece57354457e5fa2da253ec837127afa49c42a6d739
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for mini-aiohttp 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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mini_aiohttp-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA 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.