Handle duplicate content-length

This commit is contained in:
Emile Fugulin 2019-11-18 20:49:22 -05:00
parent b798412444
commit bd8670b4db
3 changed files with 12 additions and 0 deletions

View File

@ -131,6 +131,8 @@ class Message(object):
content_length = None
for (name, value) in self.headers:
if name == "CONTENT-LENGTH":
if content_length is not None:
raise InvalidHeader("CONTENT-LENGTH", req=self)
content_length = value
elif name == "TRANSFER-ENCODING":
chunked = value.lower() == "chunked"

View File

@ -0,0 +1,5 @@
GET /stuff/here?foo=bar HTTP/1.1\r\n
Content-Length: 3\r\n
Content-Length: 2\r\n
\r\n
xyz

View File

@ -0,0 +1,5 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidHeader
cfg = Config()
request = InvalidHeader