Skip to content

Commit b9d94fd

Browse files
committed
Merge remote-tracking branch 'evanj/master' into merge
2 parents 0e6540b + aaab26a commit b9d94fd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

tornado/simple_httpclient.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,10 @@ def cleanup(self):
326326

327327
def _on_close(self):
328328
if self.final_callback is not None:
329-
raise HTTPError(599, "Connection closed")
329+
message = "Connection closed"
330+
if self.stream.error:
331+
message = str(self.stream.error)
332+
raise HTTPError(599, message)
330333

331334
def _on_headers(self, data):
332335
data = native_str(data.decode("latin1"))

tornado/test/simple_httpclient_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ def test_host_header(self):
283283
response = self.wait()
284284
self.assertTrue(host_re.match(response.body), response.body)
285285

286+
def test_connection_refused(self):
287+
self.http_client.fetch("http://localhost:1/", self.stop)
288+
response = self.wait()
289+
self.assertEqual(599, response.code)
290+
self.assertIn("Connection refused", str(response.error))
291+
286292

287293
class CreateAsyncHTTPClientTestCase(AsyncTestCase, LogTrapTestCase):
288294
def setUp(self):

0 commit comments

Comments
 (0)