aioh2
HTTP/2 implementation with hyper-h2 on Python 3 asyncio.
Free software: BSD license
Documentation: https://aioh2.readthedocs.org.
Features
Asynchronous HTTP/2 client and server
Multiplexing streams of data with managed flow and priority control
Optional tickless health check
More to come
Non-features:
Request/Response wrappers
Web server, dispatcher, cookie, etc
HTTP/2 upgrade
Example
A server saying hello:
# Server request handler
async def on_connected(proto):
try:
while True:
# Receive a request from queue
stream_id, headers = await proto.recv_request()
# Send response headers
await proto.start_response(stream_id, {':status': '200'})
# Response body starts with "hello"
await proto.send_data(stream_id, b'hello, ')
# Read all request body as a name from client side
name = await proto.read_stream(stream_id, -1)
# Amend response body with the name
await proto.send_data(stream_id, name)
# Send trailers with the length of the name
await proto.send_trailers(stream_id, {'len': str(len(name))})
except asyncio.CancelledError:
# do cleanup here
pass
# Start server on random port, with maximum concurrent requests of 3
server = await aioh2.start_server(on_connected, port=0, concurrency=3)
port = server.sockets[0].getsockname()[1]
And a client to try out:
# Open client connection
client = await aioh2.open_connection('0.0.0.0', port,
functional_timeout=0.1)
# Optionally wait for an ack of tickless ping - a.k.a. until functional
await asyncio.sleep(0.1) # simulate client being busy with something else
rtt = await client.wait_functional()
if rtt:
print('Round-trip time: %.1fms' % (rtt * 1000))
# Start request with headers
stream_id = await client.start_request(
{':method': 'GET', ':path': '/index.html'})
# Send my name "world" as whole request body
await client.send_data(stream_id, b'world', end_stream=True)
# Receive response headers
headers = await client.recv_response(stream_id)
print('Response headers:', headers)
# Read all response body
resp = await client.read_stream(stream_id, -1)
print('Response body:', resp)
# Read response trailers
trailers = await client.recv_trailers(stream_id)
print('Response trailers:', trailers)
client.close_connection()
await asyncio.sleep(.1)
Above example can be found at examples/core.py.
Credits
A big thanks to the great library hyper-h2 from Cory Benfield.
DecentFoX Studio is a software outsourcing company delivering high-quality web-based products and mobile apps for global customers with agile methodology, focusing on bleeding-edge technologies and fast-developing scalable architectures.
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.2.1 (2017-12-03)
Updated to h2 3.0 (Contributed by Arthur Darcet and Peter Wu)
Dropped support for Python 3.3
0.1.0 (2016-2-6)
First release on PyPI.
Metadata
Release files for aioh2 0.2.3
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 |
|---|---|---|---|---|
| aioh2-0.2.3.tar.gz | 24.7 kB | Without provenance | Details for aioh2-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aioh2-0.2.3-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for aioh2-0.2.3-py2.py3-none-any.whl |
Total release size: 36.3 kB
Release files / aioh2-0.2.3.tar.gz
| Download URL | aioh2-0.2.3.tar.gz |
|---|---|
| Size | 24.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f6ed71db16c410abf74dbe900def8f11429ba19edcf1037b865fc03668d3bd7
|
|
BLAKE2b-256 checksum How to use checksums |
c2925f598d7475bc1df25d87614b5ad74bd20d2db2fc78270d30c9b1568939c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.13
|
Release files / aioh2-0.2.3-py2.py3-none-any.whl
| Download URL | aioh2-0.2.3-py2.py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a4d09801b46a6cc9101d6c97e1886428469db10aaa2736a45fa89d0467c75821
|
|
BLAKE2b-256 checksum How to use checksums |
f704d66eb5b20378bcb91f5b58b20fc7d5bddb4c6cec2b0892530ad7fca69416
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.13
|
Security for aioh2 0.2.3
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.