Skip to content

Instantly share code, notes, and snippets.

@walter
Created June 4, 2010 23:44
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 walter/426092 to your computer and use it in GitHub Desktop.
Save walter/426092 to your computer and use it in GitHub Desktop.
$ script/console # put the word production after this if you are normally running in production mode
...
>> require 'net/http'
>> require 'uri'
>> require 'socket'
>> url = URI.parse("http://no.wikipedia.org/wiki/Valentin_F%C3%BCrst")
>> headers = Object.const_defined?('SITE_URL') ? { "User-Agent" => "#{SITE_URL} link checking mechanism via Ruby Net/HTTP" } : { "User-Agent" => "Ruby Net/HTTp used for link checking mechanism" }
>> http = Net::HTTP.new(url.host, (url.scheme == 'https') ? 443 : 80)
>> response = http.request_head(url.path, headers) # copy and paste what this returns back into ticket
>> response = http.request_get(url.path, headers) {|r|} # copy and paste what this returns back into ticket
>> response = http.request_get(url.path) {|r|} # copy and paste what this returns back into ticket
>> exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment