Skip to content

Instantly share code, notes, and snippets.

@OriPekelman
Last active December 19, 2015 18:49
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 OriPekelman/6001691 to your computer and use it in GitHub Desktop.
Save OriPekelman/6001691 to your computer and use it in GitHub Desktop.
The HTTP gem failing urls
source 'https://rubygems.org'
gem 'http', :path =>'/Users/oripekelman/Sites/http'
gem 'sinatra'
require 'sinatra'
get '/200' do
"OK"
end
get '/301' do
redirect "/200", 301
end
get '/302' do
redirect "/200", 302
end
get '/303' do
redirect "/200", 302
end
get '/401' do
halt 401, 'go away!'
end
get '/402' do
halt 402, 'go away!'
end
get '/403' do
halt 403, 'go away!'
end
get '/404' do
halt 404, 'go away!'
end
get '/501' do
halt 501, 'Boom!'
end
get '/502' do
halt 502, 'Boom!'
end
get '/503' do
halt 503, 'Boom!'
end
require 'http'
require 'pry'
codes = [200] + (300..303).to_a + (400..404).to_a + (500..503).to_a
failing_urls = [
'http://github.com',
'https://github.com',
'http://vimeo.com',
'http://tonyarcieri.com']
sinatra_urls = codes.map {|c|"http://localhost:4567/#{c}"}
urls = [
'http://tonyarcieri.com/',
'http://gmail.com',
'http://www.unlimitednovelty.com',
'http://github.com/',
'https://github.com/',
'http://vimeo.com/',
'http://fr.wikipedia.org/wiki/Bascule_(circuit_logique)',
'http://www.google.com',
"https://btc-e.com/api/2/btc_usd/depth"] + sinatra_urls + failing_urls
urls.each do |url|
begin
response = Http.get(url).response
puts "Worked: #{response.status_code} #{url}"
rescue Exception => e
puts "Failed: #{url}"
puts e.message
puts e.backtrace.inspect
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment