File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -114,6 +114,11 @@ def test_plain_hello(self):
114114 out , err = run_amock ()
115115 self .check_hello (out )
116116
117+ def test_request_length (self ):
118+ out , err = run_amock (data = b"GET " + (b"x" * 65537 ) + b" HTTP/1.0\n \n " )
119+ self .assertEqual (out .splitlines ()[0 ],
120+ b"HTTP/1.0 414 Request-URI Too Long" )
121+
117122 def test_validated_hello (self ):
118123 out , err = run_amock (validator (hello_app ))
119124 # the middleware doesn't support len(), so content-length isn't there
Original file line number Diff line number Diff line change @@ -114,7 +114,14 @@ def get_stderr(self):
114114 def handle (self ):
115115 """Handle a single HTTP request"""
116116
117- self .raw_requestline = self .rfile .readline ()
117+ self .raw_requestline = self .rfile .readline (65537 )
118+ if len (self .raw_requestline ) > 65536 :
119+ self .requestline = ''
120+ self .request_version = ''
121+ self .command = ''
122+ self .send_error (414 )
123+ return
124+
118125 if not self .parse_request (): # An error code has been sent, just exit
119126 return
120127
Original file line number Diff line number Diff line change @@ -219,6 +219,7 @@ Denver Coneybeare
219219Geremy Condra
220220Juan José Conti
221221Matt Conway
222+ Devin Cook
222223David M. Cooke
223224Jason R. Coombs
224225Garrett Cooper
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ What's New in Python 3.2.6?
1010Library
1111-------
1212
13+ - Issue #22419: Limit the length of incoming HTTP request in wsgiref server to
14+ 65536 bytes and send a 414 error code for higher lengths. Patch contributed
15+ by Devin Cook.
16+
1317- Issue #22517: When a io.BufferedRWPair object is deallocated, clear its
1418 weakrefs.
1519
You can’t perform that action at this time.
0 commit comments