Skip to content

Commit

Permalink
Merge pull request #1282 from Yaakov-Belch/bugfix-1241-call-acknowled…
Browse files Browse the repository at this point in the history
…ge-received-data

Fix bug 1241 by calling acknowledge_received_data
  • Loading branch information
Kriechi authored Apr 30, 2024
2 parents bc005af + 94b3043 commit 0dd0bf2
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 0dd0bf2

Please sign in to comment.