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()
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()