From dc411651b6a1463880d7a1e82c9ce9da939a9167 Mon Sep 17 00:00:00 2001 From: Daniel Schwarz Date: Sat, 27 May 2017 15:36:57 +0200 Subject: [PATCH] add check for header and value --- sanic/server.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sanic/server.py b/sanic/server.py index 5ce15a1b..c2950ad0 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -166,11 +166,12 @@ class HttpProtocol(asyncio.Protocol): def on_header(self, name, value): print(f'header "{name}": "{value}"') - if name == b'Content-Length' and int(value) > self.request_max_size: - exception = PayloadTooLarge('Payload Too Large') - self.write_error(exception) + if name and value: + if name == b'Content-Length' and int(value) > self.request_max_size: + exception = PayloadTooLarge('Payload Too Large') + self.write_error(exception) - self.headers.append((name.decode().casefold(), value.decode())) + self.headers.append((name.decode().casefold(), value.decode())) def on_headers_complete(self): self.request = self.request_class(