Previously, this reported "Connection closed" for everything. This change
adds the exception info: HTTP 599: [Errno 61] Connection refused
def _on_close(self):
if self.final_callback is not None:
- raise HTTPError(599, "Connection closed")
+ message = "Connection closed"
+ if self.stream.error:
+ message = str(self.stream.error)
+ raise HTTPError(599, message)
def _on_headers(self, data):
data = native_str(data.decode("latin1"))
response = self.wait()
self.assertTrue(host_re.match(response.body), response.body)
+ def test_connection_refused(self):
+ self.http_client.fetch("http://localhost:1/", self.stop)
+ response = self.wait()
+ self.assertEqual(599, response.code)
+ self.assertIn("Connection refused", str(response.error))
+
class CreateAsyncHTTPClientTestCase(AsyncTestCase, LogTrapTestCase):
def setUp(self):