Over a million developers have joined DZone.

Ruby Remote File Checker

·

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
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}