https://github.com/buhman/mhtg
minimal h11/trio glue
https://github.com/buhman/mhtg
async http python trio
Last synced: 8 months ago
JSON representation
minimal h11/trio glue
- Host: GitHub
- URL: https://github.com/buhman/mhtg
- Owner: buhman
- License: other
- Created: 2019-04-01T05:18:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-01T06:18:26.000Z (over 6 years ago)
- Last Synced: 2025-02-08T04:25:52.257Z (9 months ago)
- Topics: async, http, python, trio
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
mhtg: minimal h11/trio glue
===========================
features
--------
- h11_, a transport agnostic standards-compliant http/1.1 implementation
- trio_, an async/await-native IO library focused on usability and correctness
.. _trio: https://github.com/python-trio/trio
.. _h11: https://github.com/python-hyper/h11
usage
-----
contrived example:
.. code-block:: python
from functools import partial
from mhtg import client, context, model
import trio
client_factory = partial(client.client_factory,
server_hostname="google.com",
port=443)
connection_manager = context.make_connection_manager(client_factory)
def request_builder():
request = h11.Request(method="GET",
target="/",
headers=[
("host", server_hostname),
("content-length", 0),
])
return request,
async def do():
async with connection_manager() as reuse_connection:
async with reuse_connection() as make_request:
await make_request(*request_builder())
trio.run(do)