{"id":13494906,"url":"https://github.com/decentfox/aioh2","last_synced_at":"2025-04-08T03:10:31.400Z","repository":{"id":52861858,"uuid":"50983296","full_name":"decentfox/aioh2","owner":"decentfox","description":"HTTP/2 implementation with hyper-h2 on Python 3 asyncio.","archived":false,"fork":false,"pushed_at":"2023-10-15T16:07:31.000Z","size":80,"stargazers_count":79,"open_issues_count":15,"forks_count":23,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-04-14T08:52:21.609Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/decentfox.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst"}},"created_at":"2016-02-03T07:48:17.000Z","updated_at":"2023-11-26T05:34:05.000Z","dependencies_parsed_at":"2024-01-16T09:52:27.541Z","dependency_job_id":"e5dc343c-f4d9-4af4-8157-55ab635a3737","html_url":"https://github.com/decentfox/aioh2","commit_stats":{"total_commits":38,"total_committers":8,"mean_commits":4.75,"dds":"0.21052631578947367","last_synced_commit":"2f9b76161e99e32317083cd2ebd17ce2ed3e41ab"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decentfox%2Faioh2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decentfox%2Faioh2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decentfox%2Faioh2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decentfox%2Faioh2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decentfox","download_url":"https://codeload.github.com/decentfox/aioh2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767236,"owners_count":20992548,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T19:01:29.319Z","updated_at":"2025-04-08T03:10:31.376Z","avatar_url":"https://github.com/decentfox.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"=====\naioh2\n=====\n\n.. image:: https://img.shields.io/pypi/v/aioh2.svg\n        :target: https://pypi.python.org/pypi/aioh2\n\n.. image:: https://img.shields.io/travis/decentfox/aioh2.svg\n        :target: https://travis-ci.org/decentfox/aioh2\n\n.. image:: https://readthedocs.org/projects/aioh2/badge/?version=latest\n        :target: https://readthedocs.org/projects/aioh2/?badge=latest\n        :alt: Documentation Status\n\n\nHTTP/2 implementation with hyper-h2_ on Python 3 asyncio.\n\n* Free software: BSD license\n* Documentation: https://aioh2.readthedocs.org.\n\nFeatures\n--------\n\n* Asynchronous HTTP/2 client and server\n* Multiplexing streams of data with managed flow and priority control\n* Optional tickless health check\n* More to come\n\nNon-features:\n\n* Request/Response wrappers\n* Web server, dispatcher, cookie, etc\n* HTTP/2 upgrade\n\nExample\n-------\n\nA server saying hello:\n\n.. code-block:: python\n\n    # Server request handler\n    async def on_connected(proto):\n        try:\n            while True:\n                # Receive a request from queue\n                stream_id, headers = await proto.recv_request()\n\n                # Send response headers\n                await proto.start_response(stream_id, {':status': '200'})\n\n                # Response body starts with \"hello\"\n                await proto.send_data(stream_id, b'hello, ')\n\n                # Read all request body as a name from client side\n                name = await proto.read_stream(stream_id, -1)\n\n                # Amend response body with the name\n                await proto.send_data(stream_id, name)\n\n                # Send trailers with the length of the name\n                await proto.send_trailers(stream_id, {'len': str(len(name))})\n        except asyncio.CancelledError:\n            # do cleanup here\n            pass\n\n    # Start server on random port, with maximum concurrent requests of 3\n    server = await aioh2.start_server(on_connected, port=0, concurrency=3)\n    port = server.sockets[0].getsockname()[1]\n\n\nAnd a client to try out:\n\n.. code-block:: python\n\n    # Open client connection\n    client = await aioh2.open_connection('0.0.0.0', port,\n                                         functional_timeout=0.1)\n\n    # Optionally wait for an ack of tickless ping - a.k.a. until functional\n    await asyncio.sleep(0.1)  # simulate client being busy with something else\n    rtt = await client.wait_functional()\n    if rtt:\n        print('Round-trip time: %.1fms' % (rtt * 1000))\n\n    # Start request with headers\n    stream_id = await client.start_request(\n        {':method': 'GET', ':path': '/index.html'})\n\n    # Send my name \"world\" as whole request body\n    await client.send_data(stream_id, b'world', end_stream=True)\n\n    # Receive response headers\n    headers = await client.recv_response(stream_id)\n    print('Response headers:', headers)\n\n    # Read all response body\n    resp = await client.read_stream(stream_id, -1)\n    print('Response body:', resp)\n\n    # Read response trailers\n    trailers = await client.recv_trailers(stream_id)\n    print('Response trailers:', trailers)\n\n    client.close_connection()\n    await asyncio.sleep(.1)\n\n\nAbove example can be found at `examples/core.py`.\n\n\nCredits\n-------\n\nA big thanks to the great library hyper-h2_ from `Cory Benfield`_.\n\n`DecentFoX Studio`_ is a software outsourcing company delivering high-quality\nweb-based products and mobile apps for global customers with agile methodology,\nfocusing on bleeding-edge technologies and fast-developing scalable architectures.\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n.. _hyper-h2: https://github.com/python-hyper/hyper-h2\n.. _`DecentFoX Studio`: http://decentfox.com\n.. _`Cory Benfield`: https://github.com/Lukasa\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecentfox%2Faioh2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecentfox%2Faioh2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecentfox%2Faioh2/lists"}