Skip to content

Commit 4f0e52e

Browse files
committed
Parse the SETTINGS header on the server side.
(cherry picked from commit 94a7902)
1 parent e200df3 commit 4f0e52e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

h2/connection.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,19 +588,29 @@ def initiate_upgrade_connection(self, settings_header=None):
588588
"""
589589
frame_data = None
590590

591+
# Begin by getting the preamble in place.
592+
self.initiate_connection()
593+
591594
if self.config.client_side:
592595
f = SettingsFrame(0)
593596
for setting, value in self.local_settings.items():
594597
f.settings[setting] = value
595598

596599
frame_data = f.serialize_body()
597600
frame_data = base64.urlsafe_b64encode(frame_data)
601+
elif settings_header:
602+
# We have a settings header from the client. This needs to be
603+
# applied, but we want to throw away the ACK. We do this by
604+
# inserting the data into a Settings frame and then passing it to
605+
# the state machine, but ignoring the return value.
606+
settings_header = base64.urlsafe_b64decode(settings_header)
607+
f = SettingsFrame(0)
608+
f.parse_body(settings_header)
609+
self._receive_settings_frame(f)
598610

599611
# Set up appropriate state. Stream 1 in a half-closed state:
600612
# half-closed(local) for clients, half-closed(remote) for servers.
601613
# Additionally, we need to set up the Connection state machine.
602-
self.initiate_connection()
603-
604614
connection_input = (
605615
ConnectionInputs.SEND_HEADERS if self.config.client_side
606616
else ConnectionInputs.RECV_HEADERS

0 commit comments

Comments
 (0)