@@ -297,16 +297,9 @@ def validate_received_setting(self, setting: SettingCodes | int, value: int) ->
297297 Clients may advertise ``ENABLE_PUSH`` only as ``0`` in received
298298 SETTINGS frames.
299299 """
300- invalid = _validate_setting (setting , value )
301- if (
302- not invalid
303- and self ._client
304- and setting == SettingCodes .ENABLE_PUSH
305- and value != 0
306- ):
307- invalid = ErrorCodes .PROTOCOL_ERROR
300+ invalid = _validate_setting (setting , value , client = self ._client )
308301
309- if invalid :
302+ if invalid != ErrorCodes . NO_ERROR :
310303 msg = f"Setting { setting } has invalid value { value } "
311304 raise InvalidSettingsValueError (
312305 msg ,
@@ -337,13 +330,20 @@ def __ne__(self, other: object) -> bool:
337330 __hash__ = MutableMapping .__hash__
338331
339332
340- def _validate_setting (setting : SettingCodes | int , value : int ) -> ErrorCodes :
333+ def _validate_setting (
334+ setting : SettingCodes | int ,
335+ value : int ,
336+ * ,
337+ client : bool = False ,
338+ ) -> ErrorCodes :
341339 """
342340 Confirms that a specific setting has a well-formed value. If the setting is
343341 invalid, returns an error code. Otherwise, returns 0 (NO_ERROR).
342+
343+ 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 ):
346+ if value not in (0 , 1 ) or ( client and value != 0 ) :
347347 return ErrorCodes .PROTOCOL_ERROR
348348 elif setting == SettingCodes .INITIAL_WINDOW_SIZE :
349349 if not 0 <= value <= 2147483647 : # 2^31 - 1
0 commit comments