File tree Expand file tree Collapse file tree 4 files changed +18
-1
lines changed Expand file tree Collapse file tree 4 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,11 @@ def test_plain_hello(self):
114
114
out , err = run_amock ()
115
115
self .check_hello (out )
116
116
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
+
117
122
def test_validated_hello (self ):
118
123
out , err = run_amock (validator (hello_app ))
119
124
# 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):
114
114
def handle (self ):
115
115
"""Handle a single HTTP request"""
116
116
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
+
118
125
if not self .parse_request (): # An error code has been sent, just exit
119
126
return
120
127
Original file line number Diff line number Diff line change @@ -219,6 +219,7 @@ Denver Coneybeare
219
219
Geremy Condra
220
220
Juan José Conti
221
221
Matt Conway
222
+ Devin Cook
222
223
David M. Cooke
223
224
Jason R. Coombs
224
225
Garrett Cooper
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ What's New in Python 3.2.6?
10
10
Library
11
11
-------
12
12
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
+
13
17
- Issue #22517: When a io.BufferedRWPair object is deallocated, clear its
14
18
weakrefs.
15
19
You can’t perform that action at this time.
0 commit comments