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

Wait until all data in buffer is flushed to client #1362

Closed
wants to merge 2 commits into from
Closed
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
22 changes: 14 additions & 8 deletions proxy/http/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class HttpProtocolHandler(BaseTcpServerHandler[HttpClientConnection]):
Accepts `Client` connection and delegates to HttpProtocolHandlerPlugin.
"""

server_teared = False

def __init__(self, *args: Any, **kwargs: Any):
super().__init__(*args, **kwargs)
self.start_time: float = time.time()
Expand Down Expand Up @@ -145,15 +147,19 @@ async def handle_events(
teardown = await self.plugin.write_to_descriptors(writables)
if teardown:
return True
# Read from ready to read sockets
teardown = await self.handle_readables(readables)
if teardown:
return True
# Invoke plugin.read_from_descriptors
if self.plugin:
teardown = await self.plugin.read_from_descriptors(readables)
if not self.server_teared:
# Read from ready to read sockets
teardown = await self.handle_readables(readables)
if teardown:
return True
self.server_teared = True
# Invoke plugin.read_from_descriptors
if self.plugin:
teardown = await self.plugin.read_from_descriptors(readables)
if teardown:
self.server_teared = True
if self.server_teared and not self.work.has_buffer():
# Wait until client buffer flushed when server teared down.
return True
return False

def handle_data(self, data: memoryview) -> Optional[bool]:
Expand Down
Loading