diff --git a/THANKS b/THANKS index 9f4c6b6b9..3bf0f6990 100644 --- a/THANKS +++ b/THANKS @@ -188,3 +188,4 @@ Xie Shi Yue Du zakdances Emile Fugulin +Oliver Allen diff --git a/gunicorn/http/parser.py b/gunicorn/http/parser.py index 88da17ab0..23f499a9a 100644 --- a/gunicorn/http/parser.py +++ b/gunicorn/http/parser.py @@ -25,17 +25,19 @@ def __init__(self, cfg, source, source_addr): def __iter__(self): return self - def __next__(self): - # Stop if HTTP dictates a stop. - if self.mesg and self.mesg.should_close(): - raise StopIteration() - + def finish_body(self): # Discard any unread body of the previous message if self.mesg: data = self.mesg.body.read(8192) while data: data = self.mesg.body.read(8192) + def __next__(self): + # Stop if HTTP dictates a stop. + if self.mesg and self.mesg.should_close(): + raise StopIteration() + self.finish_body() + # Parse the next request self.req_count += 1 self.mesg = self.mesg_class(self.cfg, self.unreader, self.source_addr, self.req_count) diff --git a/gunicorn/workers/gthread.py b/gunicorn/workers/gthread.py index 7a23228cd..0616d6173 100644 --- a/gunicorn/workers/gthread.py +++ b/gunicorn/workers/gthread.py @@ -280,6 +280,7 @@ def handle(self, conn): # handle the request keepalive = self.handle_request(req, conn) if keepalive: + conn.parser.finish_body() return (keepalive, conn) except http.errors.NoMoreData as e: self.log.debug("Ignored premature client disconnection. %s", e)