Merge pull request #2188 from benoitc/fix-input_terminated

fix wsgi.input_terminated
This commit is contained in:
Benoit Chesneau 2019-11-21 09:51:24 +01:00 committed by GitHub
commit 46b6556a68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -33,6 +33,7 @@ class Message(object):
self.version = None
self.headers = []
self.trailers = []
self.terminated = True
self.body = None
self.scheme = "https" if cfg.is_ssl else "http"
@ -151,6 +152,7 @@ class Message(object):
if content_length < 0:
raise InvalidHeader("CONTENT-LENGTH", req=self)
self.terminated = False
self.body = Body(LengthReader(self.unreader, content_length))
else:
self.body = Body(EOFReader(self.unreader))

View File

@ -82,6 +82,7 @@ def default_environ(req, sock, cfg):
env = base_environ(cfg)
env.update({
"wsgi.input": req.body,
"wsgi.input_terminated": req.terminated,
"gunicorn.socket": sock,
"REQUEST_METHOD": req.method,
"QUERY_STRING": req.query,
@ -131,7 +132,6 @@ def create(req, sock, client, server, cfg):
continue
elif hdr_name == "CONTENT-LENGTH":
environ['CONTENT_LENGTH'] = hdr_value
environ['wsgi.input_terminated'] = False
continue
key = 'HTTP_' + hdr_name.replace('-', '_')