test_ssl.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:trio 作者: python-trio 项目源码 文件源码
def test_ssl_https_compatibility_disagreement():
    client, server = ssl_memory_stream_pair(
        server_kwargs={"https_compatible": False},
        client_kwargs={"https_compatible": True}
    )

    async with _core.open_nursery() as nursery:
        nursery.start_soon(client.do_handshake)
        nursery.start_soon(server.do_handshake)

    # client is in HTTPS-mode, server is not
    # so client doing graceful_shutdown causes an error on server
    async def receive_and_expect_error():
        with pytest.raises(BrokenStreamError) as excinfo:
            await server.receive_some(10)
        assert isinstance(excinfo.value.__cause__, tssl.SSLEOFError)

    async with _core.open_nursery() as nursery:
        nursery.start_soon(client.aclose)
        nursery.start_soon(receive_and_expect_error)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号