add header_fragment handeling
This commit is contained in:
parent
dc411651b6
commit
53a04309ff
|
@ -98,6 +98,7 @@ class HttpProtocol(asyncio.Protocol):
|
||||||
self._request_handler_task = None
|
self._request_handler_task = None
|
||||||
self._request_stream_task = None
|
self._request_stream_task = None
|
||||||
self._keep_alive = keep_alive
|
self._keep_alive = keep_alive
|
||||||
|
self._header_fragment = b''
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def keep_alive(self):
|
def keep_alive(self):
|
||||||
|
@ -164,14 +165,20 @@ class HttpProtocol(asyncio.Protocol):
|
||||||
self.url = url
|
self.url = url
|
||||||
|
|
||||||
def on_header(self, name, value):
|
def on_header(self, name, value):
|
||||||
print(f'header "{name}": "{value}"')
|
log.debug('on_header', name, value)
|
||||||
|
|
||||||
if name and value:
|
self._header_fragment += name
|
||||||
if name == b'Content-Length' and int(value) > self.request_max_size:
|
|
||||||
|
if value is not None:
|
||||||
|
if self._header_fragment == b'Content-Length' and int(value) > self.request_max_size:
|
||||||
exception = PayloadTooLarge('Payload Too Large')
|
exception = PayloadTooLarge('Payload Too Large')
|
||||||
self.write_error(exception)
|
self.write_error(exception)
|
||||||
|
|
||||||
self.headers.append((name.decode().casefold(), value.decode()))
|
self.headers.append((self._header_fragment.decode().casefold(), value.decode()))
|
||||||
|
|
||||||
|
log.debug('added header', self._header_fragment, value)
|
||||||
|
|
||||||
|
self._header_fragment = b''
|
||||||
|
|
||||||
def on_headers_complete(self):
|
def on_headers_complete(self):
|
||||||
self.request = self.request_class(
|
self.request = self.request_class(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user