Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug 1241 by calling acknowledge_received_data #1282

Merged
merged 1 commit into from
Apr 30, 2024
Merged
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
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
Loading