From b3f9815aba51bd7a24b614d46c277159ce689c40 Mon Sep 17 00:00:00 2001 From: Benoit Chesneau Date: Wed, 26 Aug 2020 10:56:04 +0200 Subject: [PATCH] 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 --- gunicorn/http/message.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gunicorn/http/message.py b/gunicorn/http/message.py index 93ecf3b3..c7f795ee 100644 --- a/gunicorn/http/message.py +++ b/gunicorn/http/message.py @@ -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))