Skip to content

Commit ea1c084

Browse files
authored
[3.11] Fix WebSocket reader flow control size calculation for multi-byte data (#9686)
1 parent d4c0914 commit ea1c084

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

CHANGES/9686.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed the WebSocket flow control calculation undercounting with multi-byte data -- by :user:`bdraco`.

aiohttp/_websocket/reader_py.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from ..compression_utils import ZLibDecompressor
66
from ..helpers import set_exception
7-
from ..streams import DataQueue
7+
from ..streams import FlowControlDataQueue
88
from .helpers import UNPACK_CLOSE_CODE, UNPACK_LEN3, websocket_mask
99
from .models import (
1010
WS_DEFLATE_TRAILING,
@@ -42,7 +42,10 @@
4242

4343
class WebSocketReader:
4444
def __init__(
45-
self, queue: DataQueue[WSMessage], max_msg_size: int, compress: bool = True
45+
self,
46+
queue: FlowControlDataQueue[WSMessage],
47+
max_msg_size: int,
48+
compress: bool = True,
4649
) -> None:
4750
self.queue = queue
4851
self._queue_feed_data = queue.feed_data
@@ -185,7 +188,8 @@ def _feed_data(self, data: bytes) -> None:
185188
# This is not type safe, but many tests should fail in
186189
# test_client_ws_functional.py if this is wrong.
187190
self._queue_feed_data(
188-
TUPLE_NEW(WSMessage, (WS_MSG_TYPE_TEXT, text, "")), len(text)
191+
TUPLE_NEW(WSMessage, (WS_MSG_TYPE_TEXT, text, "")),
192+
len(payload_merged),
189193
)
190194
else:
191195
self._queue_feed_data(

docs/spelling_wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ UI
330330
un
331331
unawaited
332332
unclosed
333+
undercounting
333334
unhandled
334335
unicode
335336
unittest

tests/test_websocket_parser.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,6 @@ def test_flow_control_binary(
613613
assert protocol._reading_paused is True
614614

615615

616-
@pytest.mark.xfail(
617-
reason="Flow control is currently broken on master branch; see #9686"
618-
)
619616
def test_flow_control_multi_byte_text(
620617
protocol: BaseProtocol,
621618
out_low_limit: aiohttp.FlowControlDataQueue[WSMessage],

0 commit comments

Comments
 (0)