Skip to content

Instantly share code, notes, and snippets.

@oleander
Created October 4, 2011 23:53

Revisions

  1. oleander created this gist Oct 4, 2011.
    9 changes: 9 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    require "rest-client"

    begin
    exists = RestClient.head("http://google.com").code == 200
    rescue RestClient::Exception => error
    exists = (error.http_code != 404)
    end

    puts "exists=#{exists}"