Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit dbc7bda

Browse files
committed
Pull HTTP/2 preamble into its own method.
1 parent 2318731 commit dbc7bda

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

hyper/http20/connection.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,24 @@ def connect(self):
211211

212212
self._sock = BufferedSocket(sock, self.network_buffer_size)
213213

214-
# We need to send the connection header immediately on this
215-
# connection, followed by an initial settings frame.
216-
sock.send(b'PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n')
217-
f = SettingsFrame(0)
218-
f.settings[SettingsFrame.ENABLE_PUSH] = int(self._enable_push)
219-
self._send_cb(f)
220-
221-
# The server will also send an initial settings frame, so get it.
222-
self._recv_cb()
214+
self._send_preamble()
223215

224216
return
225217

218+
def _send_preamble(self):
219+
"""
220+
Sends the necessary HTTP/2 preamble.
221+
"""
222+
# We need to send the connection header immediately on this
223+
# connection, followed by an initial settings frame.
224+
self._sock.send(b'PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n')
225+
f = SettingsFrame(0)
226+
f.settings[SettingsFrame.ENABLE_PUSH] = int(self._enable_push)
227+
self._send_cb(f)
228+
229+
# The server will also send an initial settings frame, so get it.
230+
self._recv_cb()
231+
226232
def close(self):
227233
"""
228234
Close the connection to the server.

0 commit comments

Comments
 (0)