From 940f7aa63b8d21b62700f8c1bfa0a666b0aec3d9 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 14 Aug 2013 17:11:29 +0200 Subject: [PATCH] Use kind_of object to check if http call was successfully. --- lib/rss.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rss.rb b/lib/rss.rb index a6ff21149..2925a8a2f 100644 --- a/lib/rss.rb +++ b/lib/rss.rb @@ -9,11 +9,11 @@ module RSS response = Net::HTTP.get_response( URI.parse(url) ) # 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'] response = Net::HTTP.get_response( URI.parse( url ) ) end - if response.code.to_s != '200' + if ! response.kind_of? Net::HTTPSuccess raise "Can't fetch '#{url}', http code: #{response.code.to_s}" return end