mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
bpo-27682: Handle client connection terminations in wsgiref (GH-9713)
This commit is contained in:
parent
18029d80bd
commit
3d37ea25dc
3 changed files with 24 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue