From c30b0d9d5930bc2852964f692f8fceba35ed0d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Dzia=C5=82ak?= Date: Mon, 15 Nov 2021 11:20:23 +0100 Subject: [PATCH] Fix problem that may happen after interrupted chunk-encoding request more in bug report: https://github.com/benoitc/gunicorn/issues/2684 Fixes #2684 --- gunicorn/http/body.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gunicorn/http/body.py b/gunicorn/http/body.py index afde3685..c6e458f8 100644 --- a/gunicorn/http/body.py +++ b/gunicorn/http/body.py @@ -67,7 +67,10 @@ class ChunkedReader(object): # Remove \r\n after chunk rest = rest[size:] while len(rest) < 2: - rest += unreader.read() + new_data = unreader.read() + if not new_data: + break + rest += new_data if rest[:2] != b'\r\n': raise ChunkMissingTerminator(rest[:2]) (size, rest) = self.parse_chunk_size(unreader, data=rest[2:])