Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions gunicorn/http/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ def parse_request_line(self, line_bytes):
raise InvalidRequestMethod(self.method)
if not 3 <= len(bits[0]) <= 20:
raise InvalidRequestMethod(self.method)
# this restriction mitigates the failure to validate authority-form below
# ! do not remove simply because cfg.permit_unconventional_http_method is removed
if self.method == "CONNECT":
# BUG: method is not necessarily invalid, merely unsupported
# TODO: improve once Worker.handle_error is refactored
raise InvalidRequestMethod(self.method)
# standard restriction: RFC9110 token
if not TOKEN_RE.fullmatch(self.method):
raise InvalidRequestMethod(self.method)
Expand Down
4 changes: 4 additions & 0 deletions tests/requests/invalid/method_01.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONNECT host:25 HTTP/1.1\r\n
Content-Length: 3\r\n
\r\n
BOO
3 changes: 3 additions & 0 deletions tests/requests/invalid/method_01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from gunicorn.http.errors import InvalidRequestMethod

request = InvalidRequestMethod
4 changes: 4 additions & 0 deletions tests/requests/invalid/method_02.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONNECT domain.example HTTP/1.1\r\n
Content-Length: 3\r\n
\r\n
FOO
3 changes: 3 additions & 0 deletions tests/requests/invalid/method_02.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from gunicorn.http.errors import InvalidRequestMethod

request = InvalidRequestMethod
Loading