Skip to content

Commit

Permalink
[h3] remove SETTINGS_ prefix from setting identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaine committed Jul 14, 2021
1 parent ceebca4 commit 7cf0c66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
20 changes: 9 additions & 11 deletions src/aioquic/h3/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ class HeadersState(Enum):

class Setting(IntEnum):
QPACK_MAX_TABLE_CAPACITY = 0x1
SETTINGS_MAX_HEADER_LIST_SIZE = 0x6
MAX_HEADER_LIST_SIZE = 0x6
QPACK_BLOCKED_STREAMS = 0x7
SETTINGS_NUM_PLACEHOLDERS = 0x9
NUM_PLACEHOLDERS = 0x9
H3_DATAGRAM = 0x276
SETTINGS_ENABLE_WEBTRANSPORT = 0x2B603742
ENABLE_WEBTRANSPORT = 0x2B603742

#  Dummy setting to check it is correctly ignored by the peer.
# https://tools.ietf.org/html/draft-ietf-quic-http-34#section-7.2.4.1
Expand Down Expand Up @@ -572,7 +572,7 @@ def _get_local_settings(self) -> Dict[int, int]:
}
if self._enable_webtransport:
settings[Setting.H3_DATAGRAM] = 1
settings[Setting.SETTINGS_ENABLE_WEBTRANSPORT] = 1
settings[Setting.ENABLE_WEBTRANSPORT] = 1
return settings

def _handle_control_frame(self, frame_type: int, frame_data: bytes) -> None:
Expand Down Expand Up @@ -1053,14 +1053,12 @@ def _validate_settings(self, settings: Dict[int, int]) -> None:
"H3_DATAGRAM requires max_datagram_frame_size transport parameter"
)

if Setting.SETTINGS_ENABLE_WEBTRANSPORT in settings:
if settings[Setting.SETTINGS_ENABLE_WEBTRANSPORT] not in (0, 1):
raise SettingsError(
"SETTINGS_ENABLE_WEBTRANSPORT setting must be 0 or 1"
)
if Setting.ENABLE_WEBTRANSPORT in settings:
if settings[Setting.ENABLE_WEBTRANSPORT] not in (0, 1):
raise SettingsError("ENABLE_WEBTRANSPORT setting must be 0 or 1")

if (
settings[Setting.SETTINGS_ENABLE_WEBTRANSPORT] == 1
settings[Setting.ENABLE_WEBTRANSPORT] == 1
and settings.get(Setting.H3_DATAGRAM) != 1
):
raise SettingsError("SETTINGS_ENABLE_WEBTRANSPORT requires H3_DATAGRAM")
raise SettingsError("ENABLE_WEBTRANSPORT requires H3_DATAGRAM")
10 changes: 5 additions & 5 deletions tests/test_h3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1497,9 +1497,9 @@ def test_validate_settings_enable_webtransport_invalid_value(self):
)
h3_server = H3Connection(quic_server)

# receive SETTINGS with an invalid SETTINGS_ENABLE_WEBTRANSPORT value
# receive SETTINGS with an invalid ENABLE_WEBTRANSPORT value
settings = copy.copy(DUMMY_SETTINGS)
settings[Setting.SETTINGS_ENABLE_WEBTRANSPORT] = 2
settings[Setting.ENABLE_WEBTRANSPORT] = 2
h3_server.handle_event(
StreamDataReceived(
stream_id=2,
Expand All @@ -1512,7 +1512,7 @@ def test_validate_settings_enable_webtransport_invalid_value(self):
quic_server.closed,
(
ErrorCode.H3_SETTINGS_ERROR,
"SETTINGS_ENABLE_WEBTRANSPORT setting must be 0 or 1",
"ENABLE_WEBTRANSPORT setting must be 0 or 1",
),
)

Expand All @@ -1524,7 +1524,7 @@ def test_validate_settings_enable_webtransport_without_h3_datagram(self):

# receive SETTINGS requesting WebTransport, but DATAGRAM was not offered
settings = copy.copy(DUMMY_SETTINGS)
settings[Setting.SETTINGS_ENABLE_WEBTRANSPORT] = 1
settings[Setting.ENABLE_WEBTRANSPORT] = 1
h3_server.handle_event(
StreamDataReceived(
stream_id=2,
Expand All @@ -1537,7 +1537,7 @@ def test_validate_settings_enable_webtransport_without_h3_datagram(self):
quic_server.closed,
(
ErrorCode.H3_SETTINGS_ERROR,
"SETTINGS_ENABLE_WEBTRANSPORT requires H3_DATAGRAM",
"ENABLE_WEBTRANSPORT requires H3_DATAGRAM",
),
)

Expand Down

0 comments on commit 7cf0c66

Please sign in to comment.