Skip to content

Commit f95a7db

Browse files
committed
Align enable-push validation with RFC 9113
1 parent 5712535 commit f95a7db

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/h2/settings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,10 @@ def _validate_setting(
343343
If ``client`` is true, the setting originated from a client endpoint.
344344
"""
345345
if setting == SettingCodes.ENABLE_PUSH:
346-
if value not in (0, 1) or (client and value != 0):
346+
# RFC 9113 section 6.5.2: "A client MUST treat receipt of a
347+
# SETTINGS frame with SETTINGS_ENABLE_PUSH set to 1 as a connection
348+
# error (Section 5.4.1) of type PROTOCOL_ERROR."
349+
if value not in (0, 1) or (not client and value != 0):
347350
return ErrorCodes.PROTOCOL_ERROR
348351
elif setting == SettingCodes.INITIAL_WINDOW_SIZE:
349352
if not 0 <= value <= 2147483647: # 2^31 - 1

tests/test_invalid_frame_sequences.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,13 @@ def test_reject_invalid_settings_values(self, frame_factory, settings) -> None:
267267
h2.errors.ErrorCodes.PROTOCOL_ERROR
268268
)
269269

270-
def test_reject_client_enable_push_updates(self, frame_factory) -> None:
270+
def test_reject_server_enable_push_updates(self, frame_factory) -> None:
271271
"""
272-
Servers reject clients that advertise non-zero SETTINGS_ENABLE_PUSH
272+
Clients reject servers that advertise non-zero SETTINGS_ENABLE_PUSH
273273
values in received SETTINGS frames.
274274
"""
275-
c = h2.connection.H2Connection(config=self.server_config)
275+
c = h2.connection.H2Connection(config=self.client_config)
276276
c.initiate_connection()
277-
c.receive_data(frame_factory.preamble())
278277

279278
f = frame_factory.build_settings_frame(
280279
settings={h2.settings.SettingCodes.ENABLE_PUSH: 1},

0 commit comments

Comments
 (0)