15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/rss-motor/www.rb', line 15
def self.http_requester(httpurl)
begin
uri = URI.parse(httpurl)
http = Net::HTTP.new(uri.host, uri.port)
if httpurl.match(/^https:\/\//)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
rescue
return ''
end
return '' if response.code.match(/^4/) || response.code.match(/^5/)
return response.body if response['location'].nil?
http_requester response['location']
end
|