Debian Codegraph @

testing/web-platform/tests/tools/third_party/h2/test/test_rfc8441.py

raw
1 # -*- coding: utf-8 -*-
2 """
3 test_rfc8441
4 ~~~~~~~~~~~~
5
6 Test the RFC 8441 extended connect request support.
7 """
8 import h2.config
9 import h2.connection
10 import h2.events
11
12
13 class TestRFC8441(object):
14 """
15 Tests that the client supports sending an extended connect request
16 and the server supports receiving it.
17 """
18
19 def test_can_send_headers(self, frame_factory):
20 headers = [
21 (b':authority', b'example.com'),
22 (b':path', b'/'),
23 (b':scheme', b'https'),
24 (b':method', b'CONNECT'),
25 (b':protocol', b'websocket'),
26 (b'user-agent', b'someua/0.0.1'),
27 ]
28
29 client = h2.connection.H2Connection()
30 client.initiate_connection()
31 client.send_headers(stream_id=1, headers=headers)
32
33 server = h2.connection.H2Connection(
34 config=h2.config.H2Configuration(client_side=False)
35 )
36 events = server.receive_data(client.data_to_send())
37 event = events[1]
38 assert isinstance(event, h2.events.RequestReceived)
39 assert event.stream_id == 1
40 assert event.headers == headers