Only use request.body

This commit is contained in:
Channel Cat 2017-01-25 21:56:49 -08:00
parent 85a28d3c30
commit fd118a41fd
2 changed files with 5 additions and 7 deletions

View File

@ -54,7 +54,7 @@ class Request(dict):
self.query_string = url_parsed.query.decode('utf-8') self.query_string = url_parsed.query.decode('utf-8')
# Init but do not inhale # Init but do not inhale
self.body = None self.body = []
self.parsed_json = None self.parsed_json = None
self.parsed_form = None self.parsed_form = None
self.parsed_files = None self.parsed_files = None

View File

@ -49,7 +49,7 @@ class HttpProtocol(asyncio.Protocol):
# event loop, connection # event loop, connection
'loop', 'transport', 'connections', 'signal', 'loop', 'transport', 'connections', 'signal',
# request params # request params
'parser', 'request', 'url', 'headers', 'body', 'parser', 'request', 'url', 'headers',
# request config # request config
'request_handler', 'request_timeout', 'request_max_size', 'request_handler', 'request_timeout', 'request_max_size',
# connection management # connection management
@ -64,7 +64,6 @@ class HttpProtocol(asyncio.Protocol):
self.parser = None self.parser = None
self.url = None self.url = None
self.headers = None self.headers = None
self.body = []
self.signal = signal self.signal = signal
self.connections = connections self.connections = connections
self.request_handler = request_handler self.request_handler = request_handler
@ -149,11 +148,11 @@ class HttpProtocol(asyncio.Protocol):
) )
def on_body(self, body): def on_body(self, body):
self.body.append(body) self.request.body.append(body)
def on_message_complete(self): def on_message_complete(self):
if self.body: if self.request.body:
self.request.body = b''.join(self.body) self.request.body = b''.join(self.request.body)
self._request_handler_task = self.loop.create_task( self._request_handler_task = self.loop.create_task(
self.request_handler(self.request, self.write_response)) self.request_handler(self.request, self.write_response))
@ -217,7 +216,6 @@ class HttpProtocol(asyncio.Protocol):
self.request = None self.request = None
self.url = None self.url = None
self.headers = None self.headers = None
self.body = []
self._request_handler_task = None self._request_handler_task = None
self._total_request_size = 0 self._total_request_size = 0