Use kind_of object to check if http call was successfully.
This commit is contained in:
parent
41c26bacd7
commit
940f7aa63b
1 changed files with 2 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue