Skip to content

Commit 6545d79

Browse files
vladyslavlagemeet
authored andcommitted
Allow sending 0-byte DATA frames when flow-control window is negative
1 parent 73a232d commit 6545d79

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/h2/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ def send_data(self,
888888
"Frame size on stream ID %d is %d", stream_id, frame_size,
889889
)
890890

891-
if frame_size > self.local_flow_control_window(stream_id):
891+
if frame_size > 0 and frame_size > self.local_flow_control_window(stream_id):
892892
msg = f"Cannot send {frame_size} bytes, flow control window is {self.local_flow_control_window(stream_id)}"
893893
raise FlowControlError(msg)
894894
if frame_size > self.max_outbound_frame_size:
@@ -907,7 +907,7 @@ def send_data(self,
907907
"Outbound flow control window size is %d",
908908
self.outbound_flow_control_window,
909909
)
910-
assert self.outbound_flow_control_window >= 0
910+
assert self.outbound_flow_control_window >= 0 or frame_size == 0
911911

912912
def end_stream(self, stream_id: int) -> None:
913913
"""

src/h2/stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ def send_data(self,
981981

982982
# Subtract flow_controlled_length to account for possible padding
983983
self.outbound_flow_control_window -= df.flow_controlled_length
984-
assert self.outbound_flow_control_window >= 0
984+
assert self.outbound_flow_control_window >= 0 or df.flow_controlled_length == 0
985985

986986
return [df]
987987

0 commit comments

Comments
 (0)