Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b93e4b24
Commit
b93e4b24
authored
Apr 03, 2016
by
Martin Panter
Browse files
Options
Browse Files
Download
Plain Diff
Issue #26586: Merge excessive HTTP header handling from 3.5
parents
1862bb27
acc03195
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
0 deletions
+18
-0
Lib/http/server.py
Lib/http/server.py
+7
-0
Lib/test/test_httpservers.py
Lib/test/test_httpservers.py
+7
-0
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/http/server.py
View file @
b93e4b24
...
...
@@ -338,6 +338,13 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
HTTPStatus
.
BAD_REQUEST
,
"Line too long"
)
return
False
except
http
.
client
.
HTTPException
as
err
:
self
.
send_error
(
HTTPStatus
.
REQUEST_HEADER_FIELDS_TOO_LARGE
,
"Too many headers"
,
str
(
err
)
)
return
False
conntype
=
self
.
headers
.
get
(
'Connection'
,
""
)
if
conntype
.
lower
()
==
'close'
:
...
...
Lib/test/test_httpservers.py
View file @
b93e4b24
...
...
@@ -859,6 +859,13 @@ class BaseHTTPRequestHandlerTestCase(unittest.TestCase):
self
.
assertFalse
(
self
.
handler
.
get_called
)
self
.
assertEqual
(
self
.
handler
.
requestline
,
'GET / HTTP/1.1'
)
def
test_too_many_headers
(
self
):
result
=
self
.
send_typical_request
(
b'GET / HTTP/1.1
\
r
\
n
'
+
b'X-Foo: bar
\
r
\
n
'
*
101
+
b'
\
r
\
n
'
)
self
.
assertEqual
(
result
[
0
],
b'HTTP/1.1 431 Too many headers
\
r
\
n
'
)
self
.
assertFalse
(
self
.
handler
.
get_called
)
self
.
assertEqual
(
self
.
handler
.
requestline
,
'GET / HTTP/1.1'
)
def
test_close_connection
(
self
):
# handle_one_request() should be repeatedly called until
# it sets close_connection
...
...
Misc/NEWS
View file @
b93e4b24
...
...
@@ -237,6 +237,10 @@ Core and Builtins
Library
-------
-
Issue
#
26586
:
In
http
.
server
,
respond
with
"413 Request header fields too
large"
if
there
are
too
many
header
fields
to
parse
,
rather
than
killing
the
connection
and
raising
an
unhandled
exception
.
Patch
by
Xiang
Zhang
.
-
Issue
#
26676
:
Added
missing
XMLPullParser
to
ElementTree
.
__all__
.
-
Issue
#
22854
:
Change
BufferedReader
.
writable
()
and
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment