Use kind_of object to check if http call was successfully.

This commit is contained in:
Martin Edenhofer 2013-08-14 17:11:29 +02:00
parent 41c26bacd7
commit 940f7aa63b

View file

@ -9,11 +9,11 @@ module RSS
response = Net::HTTP.get_response( URI.parse(url) ) response = Net::HTTP.get_response( URI.parse(url) )
# check if redirect is needed # check if redirect is needed
if response.code.to_s == '301' || response.code.to_s == '302' if response.kind_of? Net::HTTPRedirection
url = response.header['location'] url = response.header['location']
response = Net::HTTP.get_response( URI.parse( url ) ) response = Net::HTTP.get_response( URI.parse( url ) )
end end
if response.code.to_s != '200' if ! response.kind_of? Net::HTTPSuccess
raise "Can't fetch '#{url}', http code: #{response.code.to_s}" raise "Can't fetch '#{url}', http code: #{response.code.to_s}"
return return
end end