Skip to content

Instantly share code, notes, and snippets.

@remvee
Created May 3, 2012 14:38
Show Gist options
  • Select an option

  • Save remvee/2586086 to your computer and use it in GitHub Desktop.

Select an option

Save remvee/2586086 to your computer and use it in GitHub Desktop.
Net::HTTP HEAD request to test if resource is available
def resource_available?(url)
uri = URI(url)
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == "https") do |http|
http.head(uri.request_uri)
end.code =~ /^[123]/
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment