Created
August 1, 2011 17:04
-
-
Save dingsdax/1118528 to your computer and use it in GitHub Desktop.
Ruby remote file checker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from http://snippets.dzone.com/posts/show/4638 | |
require 'rubygems' | |
require 'open-uri' | |
require 'net/http' | |
def remote_file_exists?(url) | |
url = URI.parse(url) | |
Net::HTTP.start(url.host, url.port) do |http| | |
return http.head(url.request_uri).code == "200" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment