Is there a way to detect a redirection in Ruby ?
I just want to know if the link gets redirected, without downloading a page and checking for exceptions.
The faster it is, the better.
Is there a way to detect a redirection in Ruby ?
I just want to know if the link gets redirected, without downloading a page and checking for exceptions.
The faster it is, the better.
http://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html#method-i-head
response = nil
Net::HTTP.start('some.www.server', 80) {|http|
response = http.head('/index.html')
}
head
call gets just only the header and you can check the response code to detect the redirection.