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
3d37ea25
Commit
3d37ea25
authored
May 01, 2019
by
Petter Strandmark
Committed by
Berker Peksag
May 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-27682: Handle client connection terminations in wsgiref (GH-9713)
parent
18029d80
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
0 deletions
+24
-0
Lib/test/test_wsgiref.py
Lib/test/test_wsgiref.py
+18
-0
Lib/wsgiref/handlers.py
Lib/wsgiref/handlers.py
+4
-0
Misc/NEWS.d/next/Library/2018-10-05-16-01-00.bpo-34547.abbaa.rst
...WS.d/next/Library/2018-10-05-16-01-00.bpo-34547.abbaa.rst
+2
-0
No files found.
Lib/test/test_wsgiref.py
View file @
3d37ea25
...
...
@@ -788,6 +788,24 @@ class HandlerTests(TestCase):
b"Hello, world!"
,
written
)
def
testClientConnectionTerminations
(
self
):
environ
=
{
"SERVER_PROTOCOL"
:
"HTTP/1.0"
}
for
exception
in
(
ConnectionAbortedError
,
BrokenPipeError
,
ConnectionResetError
,
):
with
self
.
subTest
(
exception
=
exception
):
class
AbortingWriter
:
def
write
(
self
,
b
):
raise
exception
stderr
=
StringIO
()
h
=
SimpleHandler
(
BytesIO
(),
AbortingWriter
(),
stderr
,
environ
)
h
.
run
(
hello_app
)
self
.
assertFalse
(
stderr
.
getvalue
())
if
__name__
==
"__main__"
:
unittest
.
main
()
Lib/wsgiref/handlers.py
View file @
3d37ea25
...
...
@@ -136,6 +136,10 @@ class BaseHandler:
self
.
setup_environ
()
self
.
result
=
application
(
self
.
environ
,
self
.
start_response
)
self
.
finish_response
()
except
(
ConnectionAbortedError
,
BrokenPipeError
,
ConnectionResetError
):
# We expect the client to close the connection abruptly from time
# to time.
return
except
:
try
:
self
.
handle_error
()
...
...
Misc/NEWS.d/next/Library/2018-10-05-16-01-00.bpo-34547.abbaa.rst
0 → 100644
View file @
3d37ea25
:class:`wsgiref.handlers.BaseHandler` now handles abrupt client connection
terminations gracefully. Patch by Petter Strandmark.
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