Created
May 3, 2012 14:38
-
-
Save remvee/2586086 to your computer and use it in GitHub Desktop.
Net::HTTP HEAD request to test if resource is available
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
| 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