File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,6 +118,11 @@ def test_plain_hello(self):
118118 out , err = run_amock ()
119119 self .check_hello (out )
120120
121+ def test_request_length (self ):
122+ out , err = run_amock (data = b"GET " + (b"x" * 65537 ) + b" HTTP/1.0\n \n " )
123+ self .assertEqual (out .splitlines ()[0 ],
124+ b"HTTP/1.0 414 Request-URI Too Long" )
125+
121126 def test_validated_hello (self ):
122127 out , err = run_amock (validator (hello_app ))
123128 # the middleware doesn't support len(), so content-length isn't there
Original file line number Diff line number Diff line change @@ -115,7 +115,14 @@ def get_stderr(self):
115115 def handle (self ):
116116 """Handle a single HTTP request"""
117117
118- self .raw_requestline = self .rfile .readline ()
118+ self .raw_requestline = self .rfile .readline (65537 )
119+ if len (self .raw_requestline ) > 65536 :
120+ self .requestline = ''
121+ self .request_version = ''
122+ self .command = ''
123+ self .send_error (414 )
124+ return
125+
119126 if not self .parse_request (): # An error code has been sent, just exit
120127 return
121128
Original file line number Diff line number Diff line change @@ -251,6 +251,7 @@ Denver Coneybeare
251251Phil Connell
252252Juan José Conti
253253Matt Conway
254+ Devin Cook
254255David M. Cooke
255256Jason R. Coombs
256257Garrett Cooper
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ Core and Builtins
1313Library
1414-------
1515
16+ - Issue #22419: Limit the length of incoming HTTP request in wsgiref server to
17+ 65536 bytes and send a 414 error code for higher lengths. Patch contributed
18+ by Devin Cook.
19+
1620- Lax cookie parsing in http.cookies could be a security issue when combined
1721 with non-standard cookie handling in some Web browsers. Reported by
1822 Sergey Bobrov.
You can’t perform that action at this time.
0 commit comments