Fix slow upload
This commit is contained in:
parent
0ad31a471b
commit
85a28d3c30
|
@ -49,7 +49,7 @@ class HttpProtocol(asyncio.Protocol):
|
|||
# event loop, connection
|
||||
'loop', 'transport', 'connections', 'signal',
|
||||
# request params
|
||||
'parser', 'request', 'url', 'headers',
|
||||
'parser', 'request', 'url', 'headers', 'body',
|
||||
# request config
|
||||
'request_handler', 'request_timeout', 'request_max_size',
|
||||
# connection management
|
||||
|
@ -64,6 +64,7 @@ class HttpProtocol(asyncio.Protocol):
|
|||
self.parser = None
|
||||
self.url = None
|
||||
self.headers = None
|
||||
self.body = []
|
||||
self.signal = signal
|
||||
self.connections = connections
|
||||
self.request_handler = request_handler
|
||||
|
@ -148,12 +149,11 @@ class HttpProtocol(asyncio.Protocol):
|
|||
)
|
||||
|
||||
def on_body(self, body):
|
||||
if self.request.body:
|
||||
self.request.body += body
|
||||
else:
|
||||
self.request.body = body
|
||||
self.body.append(body)
|
||||
|
||||
def on_message_complete(self):
|
||||
if self.body:
|
||||
self.request.body = b''.join(self.body)
|
||||
self._request_handler_task = self.loop.create_task(
|
||||
self.request_handler(self.request, self.write_response))
|
||||
|
||||
|
@ -217,6 +217,7 @@ class HttpProtocol(asyncio.Protocol):
|
|||
self.request = None
|
||||
self.url = None
|
||||
self.headers = None
|
||||
self.body = []
|
||||
self._request_handler_task = None
|
||||
self._total_request_size = 0
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user