Updating Content-Length Handling

Signed-off-by: Jason Myers <jmyers@syntellis.com>
This commit is contained in:
Jason Myers 2023-05-30 20:42:13 -05:00
parent add8a4c951
commit fa94f70529
7 changed files with 28 additions and 1 deletions

View File

@ -139,7 +139,10 @@ class Message(object):
self.body = Body(ChunkedReader(self, self.unreader))
elif content_length is not None:
try:
content_length = int(content_length)
if str(content_length).isnumeric():
content_length = int(content_length)
else:
raise InvalidHeader("CONTENT-LENGTH", req=self)
except ValueError:
raise InvalidHeader("CONTENT-LENGTH", req=self)

View File

@ -0,0 +1,3 @@
GET /first HTTP/1.0\r\n
Content-Length: -0\r\n
\r\n

View File

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

View File

@ -0,0 +1,3 @@
GET /first HTTP/1.0\r\n
Content-Length: 0_1\r\n
\r\n

View File

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

View File

@ -0,0 +1,3 @@
GET /first HTTP/1.0\r\n
Content-Length: +1\r\n
\r\n

View File

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