bpo-27682: Handle client connection terminations in wsgiref (GH-9713)

(cherry picked from commit 3d37ea25dc97e4cb024045581979570835deb13c)

Co-authored-by: Petter Strandmark <petter.strandmark@gmail.com>
diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py
index 8422b30..5502ece 100644
--- a/Lib/test/test_wsgiref.py
+++ b/Lib/test/test_wsgiref.py
@@ -780,6 +780,24 @@
             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()