From 052f246d55e95159dbd2ef68225ab181a75b8eac Mon Sep 17 00:00:00 2001 From: Andrew Havens Date: Fri, 31 Mar 2017 16:32:01 -0700 Subject: [PATCH] Rescue from connection refused errors and return the appropriate status code --- lib/rack_reverse_proxy/roundtrip.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/rack_reverse_proxy/roundtrip.rb b/lib/rack_reverse_proxy/roundtrip.rb index 3b10331..789b34c 100644 --- a/lib/rack_reverse_proxy/roundtrip.rb +++ b/lib/rack_reverse_proxy/roundtrip.rb @@ -166,6 +166,9 @@ def rack_response_headers format_headers(target_response.headers) ) ) + rescue Errno::ECONNREFUSED => e + @_target_response = Struct.new(:status, :body).new(502, []) + {} end def replace_location_header