|
73 | 73 | ]
|
74 | 74 | )
|
75 | 75 |
|
| 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 | + |
76 | 96 | INVALID_REQUEST_TEMPLATE = b"\r\n".join(
|
77 | 97 | [
|
78 | 98 | b"%s",
|
@@ -683,6 +703,24 @@ def test_supported_upgrade_request(protocol_cls, event_loop):
|
683 | 703 | assert b"HTTP/1.1 426 " in protocol.transport.buffer
|
684 | 704 |
|
685 | 705 |
|
| 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 | + |
686 | 724 | async def asgi3app(scope, receive, send):
|
687 | 725 | pass
|
688 | 726 |
|
|
0 commit comments