跳转到主要内容

mhtg

项目描述

特点

  • h11,一个传输无关的符合标准的http/1.1实现

  • trio,一个专注于可用性和正确性的async/await原生IO库

用法

虚构示例

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)

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面