Module: Castanet::Testing::ConnectionTesting
- Included in:
- CommonTasks
- Defined in:
- lib/castanet/testing/connection_testing.rb
Constant Summary collapse
- LOGGER =
Logger.new($stderr)
Instance Method Summary collapse
Instance Method Details
#responding?(url, logger = LOGGER) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/castanet/testing/connection_testing.rb', line 11 def responding?(url, logger = LOGGER) uri = URI(url) begin h = Net::HTTP.new(uri.host, uri.port) h.use_ssl = (uri.scheme == 'https') h.verify_mode = OpenSSL::SSL::VERIFY_NONE resp = h.get(uri.request_uri) code = resp.code.to_i (200..399).include?(code) rescue => e logger.debug "#{url}: #{e.class} (#{e.})" false end end |