Skip to content

Instantly share code, notes, and snippets.

@codingfoo
Created July 14, 2012 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingfoo/3113794 to your computer and use it in GitHub Desktop.
Save codingfoo/3113794 to your computer and use it in GitHub Desktop.
Check if remote url exists
def remote_url_exists?(url)
begin
url = URI.parse(url)
Net::HTTP.start(url.host, url.port) do |http|
return http.head(url.request_uri).code == "200"
end
rescue
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment