Пример #1
0
async def test_send_push(stream: HTTPStream, http_scope: HTTPScope) -> None:
    stream.scope = http_scope
    stream.stream_id = 1
    await stream.app_send({"type": "http.response.push", "path": "/push", "headers": []})
    assert stream.send.call_args_list == [  # type: ignore
        call(
            Request(
                stream_id=1,
                headers=[(b":scheme", b"https")],
                http_version="2",
                method="GET",
                raw_path=b"/push",
            )
        )
    ]
Пример #2
0
async def test_send_push(stream: HTTPStream) -> None:
    stream.scope = {
        "scheme": "https",
        "headers": [(b"host", b"hypercorn")],
        "http_version": "2"
    }
    stream.stream_id = 1
    await stream.app_send({
        "type": "http.response.push",
        "path": "/push",
        "headers": []
    })
    assert stream.send.call_args_list == [
        call(
            Request(
                stream_id=1,
                headers=[(b":scheme", b"https"),
                         (b":authority", b"hypercorn")],
                http_version="2",
                method="GET",
                raw_path=b"/push",
            ))
    ]