Skip to content

Commit

Permalink
Fix bug 1241 by calling acknowledge_received_data
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaakov Belch committed Apr 30, 2024
1 parent bc005af commit 94b3043
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions examples/asyncio/asyncio-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def data_received(self, data: bytes):
if isinstance(event, RequestReceived):
self.request_received(event.headers, event.stream_id)
elif isinstance(event, DataReceived):
self.receive_data(event.data, event.stream_id)
self.receive_data(
event.data, event.flow_controlled_length, event.stream_id
)
elif isinstance(event, StreamEnded):
self.stream_complete(event.stream_id)
elif isinstance(event, ConnectionTerminated):
Expand Down Expand Up @@ -109,10 +111,12 @@ def stream_complete(self, stream_id: int):
self.conn.send_headers(stream_id, response_headers)
asyncio.ensure_future(self.send_data(data, stream_id))

def receive_data(self, data: bytes, stream_id: int):
def receive_data(self, data: bytes, flow_controlled_length: int, stream_id: int):
"""
We've received some data on a stream. If that stream is one we're
expecting data on, save it off. Otherwise, reset the stream.
expecting data on, save it off (and account for the received amount of
data in flow control so that the client can send more data).
Otherwise, reset the stream.
"""
try:
stream_data = self.stream_data[stream_id]
Expand All @@ -122,6 +126,7 @@ def receive_data(self, data: bytes, stream_id: int):
)
else:
stream_data.data.write(data)
self.conn.acknowledge_received_data(flow_controlled_length, stream_id)

def stream_reset(self, stream_id):
"""
Expand Down

0 comments on commit 94b3043

Please sign in to comment.