Merge pull request #756 from qwesda/master
fixes #755 fragmented headers
This commit is contained in:
commit
1e75265eed
|
@ -99,6 +99,7 @@ class HttpProtocol(asyncio.Protocol):
|
|||
self._request_handler_task = None
|
||||
self._request_stream_task = None
|
||||
self._keep_alive = keep_alive
|
||||
self._header_fragment = b''
|
||||
self.state = state if state else {}
|
||||
if 'requests_count' not in self.state:
|
||||
self.state['requests_count'] = 0
|
||||
|
@ -173,14 +174,25 @@ class HttpProtocol(asyncio.Protocol):
|
|||
self.write_error(exception)
|
||||
|
||||
def on_url(self, url):
|
||||
self.url = url
|
||||
if not self.url:
|
||||
self.url = url
|
||||
else:
|
||||
self.url += url
|
||||
|
||||
def on_header(self, name, value):
|
||||
if name == b'Content-Length' and int(value) > self.request_max_size:
|
||||
exception = PayloadTooLarge('Payload Too Large')
|
||||
self.write_error(exception)
|
||||
self._header_fragment += name
|
||||
|
||||
self.headers.append((name.decode().casefold(), value.decode()))
|
||||
if value is not None:
|
||||
if self._header_fragment == b'Content-Length' \
|
||||
and int(value) > self.request_max_size:
|
||||
exception = PayloadTooLarge('Payload Too Large')
|
||||
self.write_error(exception)
|
||||
|
||||
self.headers.append(
|
||||
(self._header_fragment.decode().casefold(),
|
||||
value.decode()))
|
||||
|
||||
self._header_fragment = b''
|
||||
|
||||
def on_headers_complete(self):
|
||||
self.request = self.request_class(
|
||||
|
|
Loading…
Reference in New Issue
Block a user