* fix abort call errors out when calling inside stream handler

* handle pending task properly after cleanup
This commit is contained in:
7 2019-12-16 07:46:18 -08:00 committed by Stephen Sadowski
parent 2d72874b0b
commit 028778ed56

View File

@ -364,6 +364,21 @@ class HttpProtocol(asyncio.Protocol):
else: else:
self.request.body_push(body) self.request.body_push(body)
async def body_append(self, body):
if (
self.request is None
or self._request_stream_task is None
or self._request_stream_task.cancelled()
):
return
if self.request.stream.is_full():
self.transport.pause_reading()
await self.request.stream.put(body)
self.transport.resume_reading()
else:
await self.request.stream.put(body)
async def stream_append(self): async def stream_append(self):
while self._body_chunks: while self._body_chunks:
body = self._body_chunks.popleft() body = self._body_chunks.popleft()