Allow sending 0-byte DATA frames when flow-control window is negative by lagemeet · Pull Request #1314 · python-hyper/h2 · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.rst
4 changes: 2 additions & 2 deletions src/h2/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ def send_data(self,
"Frame size on stream ID %d is %d", stream_id, frame_size,
)

if frame_size > self.local_flow_control_window(stream_id):
if frame_size > 0 and frame_size > self.local_flow_control_window(stream_id):
msg = f"Cannot send {frame_size} bytes, flow control window is {self.local_flow_control_window(stream_id)}"
raise FlowControlError(msg)
if frame_size > self.max_outbound_frame_size:
Expand All @@ -907,7 +907,7 @@ def send_data(self,
"Outbound flow control window size is %d",
self.outbound_flow_control_window,
)
assert self.outbound_flow_control_window >= 0
assert self.outbound_flow_control_window >= 0 or frame_size == 0

def end_stream(self, stream_id: int) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion src/h2/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ def send_data(self,

# Subtract flow_controlled_length to account for possible padding
self.outbound_flow_control_window -= df.flow_controlled_length
assert self.outbound_flow_control_window >= 0
assert self.outbound_flow_control_window >= 0 or df.flow_controlled_length == 0

return [df]

Expand Down
11 changes: 11 additions & 0 deletions tests/test_flow_control_window.py