Skip to content

Commit 8160505

Browse files
committed
fix request body handling - fixes #3301
1 parent 903792f commit 8160505

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

gunicorn/http/parser.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,19 @@ def __init__(self, cfg, source, source_addr):
2525
def __iter__(self):
2626
return self
2727

28-
def __next__(self):
29-
# Stop if HTTP dictates a stop.
30-
if self.mesg and self.mesg.should_close():
31-
raise StopIteration()
32-
28+
def finish_body(self):
3329
# Discard any unread body of the previous message
3430
if self.mesg:
3531
data = self.mesg.body.read(8192)
3632
while data:
3733
data = self.mesg.body.read(8192)
3834

35+
def __next__(self):
36+
# Stop if HTTP dictates a stop.
37+
if self.mesg and self.mesg.should_close():
38+
raise StopIteration()
39+
self.finish_body()
40+
3941
# Parse the next request
4042
self.req_count += 1
4143
self.mesg = self.mesg_class(self.cfg, self.unreader, self.source_addr, self.req_count)

gunicorn/workers/gthread.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ def handle(self, conn):
280280
# handle the request
281281
keepalive = self.handle_request(req, conn)
282282
if keepalive:
283+
conn.parser.finish_body()
283284
return (keepalive, conn)
284285
except http.errors.NoMoreData as e:
285286
self.log.debug("Ignored premature client disconnection. %s", e)

0 commit comments

Comments
 (0)