diff options
author | Petter Strandmark <petter.strandmark@gmail.com> | 2019-05-01 17:32:15 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2019-05-01 17:32:15 (GMT) |
commit | 3d37ea25dc97e4cb024045581979570835deb13c (patch) | |
tree | e853f9899517613c1b01f41e7ec4811a24933d8c /Lib/test | |
parent | 18029d80bde1743da6900600633f0fa54d7c1044 (diff) | |
download | cpython-3d37ea25dc97e4cb024045581979570835deb13c.zip cpython-3d37ea25dc97e4cb024045581979570835deb13c.tar.gz cpython-3d37ea25dc97e4cb024045581979570835deb13c.tar.bz2 |
bpo-27682: Handle client connection terminations in wsgiref (GH-9713)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_wsgiref.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py index 737dfed..46f88a9 100644 --- a/Lib/test/test_wsgiref.py +++ b/Lib/test/test_wsgiref.py @@ -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() |