This repository was archived by the owner on Jan 13, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 10
10
import threading
11
11
import hyper
12
12
from hyper import HTTP20Connection
13
+ from hyper .http20 .frame import Frame , SettingsFrame
13
14
from server import SocketLevelTest
14
15
15
16
# Turn off certificate verification for the tests.
@@ -46,3 +47,40 @@ def socket_handler(listener):
46
47
assert data [0 ] == b'PRI * HTTP/2.0\r \n \r \n SM\r \n \r \n '
47
48
48
49
self .tear_down ()
50
+
51
+ def test_initial_settings (self ):
52
+ self .set_up ()
53
+
54
+ # Confirm that we send the connection upgrade string and the initial
55
+ # SettingsFrame.
56
+ data = []
57
+ send_event = threading .Event ()
58
+
59
+ def socket_handler (listener ):
60
+ sock = listener .accept ()[0 ]
61
+
62
+ # We should get two packets: one connection header string, one
63
+ # SettingsFrame.
64
+ first = sock .recv (65535 )
65
+ second = sock .recv (65535 )
66
+ data .append (first )
67
+ data .append (second )
68
+
69
+ send_event .set ()
70
+ sock .close ()
71
+
72
+ self ._start_server (socket_handler )
73
+ conn = HTTP20Connection (self .host , self .port )
74
+ conn .connect ()
75
+ send_event .wait ()
76
+
77
+ # Get the second chunk of data and decode it into a frame.
78
+ data = data [1 ]
79
+ f , length = Frame .parse_frame_header (data [:8 ])
80
+ f .parse_body (data [8 :])
81
+
82
+ assert isinstance (f , SettingsFrame )
83
+ assert f .stream_id == 0
84
+ assert f .settings == {SettingsFrame .ENABLE_PUSH : 0 }
85
+
86
+ self .tear_down ()
You can’t perform that action at this time.
0 commit comments