add check for header and value

This commit is contained in:
Daniel Schwarz 2017-05-27 15:36:57 +02:00
parent 514540b90b
commit dc411651b6

View File

@ -166,6 +166,7 @@ class HttpProtocol(asyncio.Protocol):
def on_header(self, name, value): def on_header(self, name, value):
print(f'header "{name}": "{value}"') print(f'header "{name}": "{value}"')
if name and value:
if name == b'Content-Length' and int(value) > self.request_max_size: if name == 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)