Added new UserAgent lib to handle ftp/http/https calls.
This commit is contained in:
parent
ad579d8237
commit
d6c49d08ad
1 changed files with 3 additions and 9 deletions
12
lib/rss.rb
12
lib/rss.rb
|
@ -7,14 +7,8 @@ module Rss
|
|||
|
||||
begin
|
||||
puts 'fetch rss...'
|
||||
response = Net::HTTP.get_response( URI.parse(url) )
|
||||
|
||||
# check if redirect is needed
|
||||
if response.kind_of? Net::HTTPRedirection
|
||||
url = response.header['location']
|
||||
response = Net::HTTP.get_response( URI.parse( url ) )
|
||||
end
|
||||
if ! response.kind_of? Net::HTTPSuccess
|
||||
response = UserAgent.request(url)
|
||||
if !response.success?
|
||||
raise "Can't fetch '#{url}', http code: #{response.code.to_s}"
|
||||
return
|
||||
end
|
||||
|
@ -42,4 +36,4 @@ module Rss
|
|||
|
||||
return items
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue