Skip to content

Instantly share code, notes, and snippets.

@thesp0nge
Created March 1, 2012 10:18
Show Gist options
  • Save thesp0nge/1948761 to your computer and use it in GitHub Desktop.
Save thesp0nge/1948761 to your computer and use it in GitHub Desktop.
Content-Type enumerator
require 'net/http'
require 'rainbow'
url_list = File.open(ARGV[0], 'r').readlines
if url_list.nil?
puts "aiee: missing url list".color(:red)
end
url_list.each do |url|
response = nil
uri = URL(url)
Net::HTTP.start(uri.host, url.port) {|http|
response = http.head('/'+uri.request_uri.chomp)
printf "/#{uri.request_uri.chomp}: ".color(:white)
printf "#{response['content-type']}\n".color(:yellow)
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment