fix: don't enforce the content length

we were trying to enforce the content length when the websocket
key was received but we should instead rely on the headers provided in
the request. Enforcing the expectation of the content length should be
done by the client side not by us.

Changes:

* remove content-length header enforcing in message.p when the
"Sec-WebSocket-Key1" header was found
This commit is contained in:
Benoit Chesneau 2020-08-26 10:56:04 +02:00
parent b80a329354
commit b3f9815aba

View File

@ -131,6 +131,7 @@ class Message(object):
def set_body_reader(self):
chunked = False
content_length = None
for (name, value) in self.headers:
if name == "CONTENT-LENGTH":
if content_length is not None:
@ -139,8 +140,6 @@ class Message(object):
elif name == "TRANSFER-ENCODING":
if value.lower() == "chunked":
chunked = True
elif name == "SEC-WEBSOCKET-KEY1":
content_length = 8
if chunked:
self.body = Body(ChunkedReader(self, self.unreader))