lib/percy/network_helpers.rb in percy-common-3.1.6 vs lib/percy/network_helpers.rb in percy-common-3.1.7.pre.beta

- old
+ new

@@ -26,27 +26,28 @@ rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::EADDRINUSE false end end - def self.verify_healthcheck(url:, expected_body: 'ok', retry_wait_seconds: 0.5, proxy: nil) + def self.verify_healthcheck(url:, expected_body: 'ok', retry_wait_seconds: 0.5, proxy: nil, + headers: {}) 10.times do begin - response = Excon.get(url, proxy: proxy) + response = Excon.get(url, proxy: proxy, headers: headers) return true if response.body == expected_body rescue Excon::Error::Socket, Excon::Error::Timeout sleep retry_wait_seconds end end raise ServerDown, "Healthcheck failed for #{url}" end def self.verify_http_server_up(hostname, port: nil, - path: nil, retry_wait_seconds: 0.25, proxy: nil) + path: nil, retry_wait_seconds: 0.25, proxy: nil, headers: {}) 10.times do begin url = "http://#{hostname}#{port.nil? ? '' : ':' + port.to_s}#{path || ''}" - Excon.get(url, proxy: proxy) + Excon.get(url, proxy: proxy, headers: headers) return true rescue Excon::Error::Socket, Excon::Error::Timeout sleep retry_wait_seconds end end