This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

HTTP/2 implementation with hyper-h2 on Python 3 asyncio.

Project Description

aioh2

HTTP/2 implementation with hyper-h2 on Python 3 asyncio.

Features

  • Asynchronous HTTP/2 client and server
  • Managed flow control
  • More to come

Example

# Server request handler
async def on_connected(proto):
    while True:
        # Receive request
        stream_id, headers = await proto.recv_request()

        # Send response headers
        await proto.send_headers(stream_id, {':status': '200'})

        # Send some response
        await proto.send_data(stream_id, b'hello, ')

        # Read all request body
        resp = await proto.read_stream(stream_id, -1)

        # Send more response
        await proto.send_data(stream_id, resp)

        # Send trailers
        await proto.send_headers(stream_id, {'len': str(len(resp))},
                                 end_stream=True)

# Start server on random port, with maximum concurrent requests of 3
server = await aioh2.start_server(
    lambda p: asyncio.get_event_loop().create_task(on_connected(p)),
    port=0, concurrency=3)
port = server.sockets[0].getsockname()[1]

# Open client connection
client = await aioh2.open_connection('0.0.0.0', port)

# Start request with headers
stream_id = await client.start_request(
    {':method': 'GET', ':path': '/index.html'})

# Send request body
await client.send_data(stream_id, b'world', end_stream=True)

# Receive response
headers = await client.recv_response(stream_id)
print(headers)

# Read all response body
resp = await client.read_stream(stream_id, -1)
print(resp)

# Read response trailers
trailers = await client.recv_trailers(stream_id)
print(trailers)

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2016-1-22)

  • First release on PyPI.
Release History

Release History

This version
History Node

0.1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
aioh2-0.1.0-py2.py3-none-any.whl (8.0 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Feb 6, 2016
aioh2-0.1.0.tar.gz (18.6 kB) Copy SHA256 Checksum SHA256 Source Feb 6, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting