Skip to content

Commit 81f21be

Browse files
committed
Added a couple of EMPTY tests (h2c & PRI-h2)
1 parent 56140b9 commit 81f21be

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/protocols/test_http.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@
7373
]
7474
)
7575

76+
UPGRADE_REQUEST_h2c = b"\r\n".join(
77+
[
78+
b"GET / HTTP/1.1",
79+
b"Host: example.org",
80+
b"Upgrade: h2c",
81+
b"HTTP2-Settings: SomeHTTP2Setting",
82+
b"",
83+
b"",
84+
]
85+
)
86+
87+
UPGRADE_REQUEST_HTTP2_PRIOR = b"\r\n".join(
88+
[
89+
b"PRI * HTTP/2.0",
90+
b"",
91+
b"",
92+
]
93+
)
94+
95+
7696
INVALID_REQUEST_TEMPLATE = b"\r\n".join(
7797
[
7898
b"%s",
@@ -683,6 +703,24 @@ def test_supported_upgrade_request(protocol_cls, event_loop):
683703
assert b"HTTP/1.1 426 " in protocol.transport.buffer
684704

685705

706+
@pytest.mark.parametrize("protocol_cls", [H11Protocol])
707+
def test_h2c_upgrade_request(protocol_cls, event_loop):
708+
app = Response("Hello, world", media_type="text/plain")
709+
710+
with get_connected_protocol(app, protocol_cls, event_loop) as protocol:
711+
protocol.data_received(UPGRADE_REQUEST_h2c)
712+
# TODO: check h2c_upgrade_request response
713+
714+
715+
@pytest.mark.parametrize("protocol_cls", [H11Protocol])
716+
def test_h2_prior_upgrade_request(protocol_cls, event_loop):
717+
app = Response("Hello, world", media_type="text/plain")
718+
719+
with get_connected_protocol(app, protocol_cls, event_loop) as protocol:
720+
protocol.data_received(UPGRADE_REQUEST_HTTP2_PRIOR)
721+
# TODO: check h2_prior_upgrade_request response
722+
723+
686724
async def asgi3app(scope, receive, send):
687725
pass
688726

0 commit comments

Comments
 (0)