fix https cert error
This commit is contained in:
parent
19807613c2
commit
782e282058
|
@ -49,19 +49,29 @@ class SiteFeed
|
||||||
anns
|
anns
|
||||||
end
|
end
|
||||||
def get_response_body(uri)
|
def get_response_body(uri)
|
||||||
res = Net::HTTP.get_response(uri)
|
res = Net::HTTP.start(uri.host, uri.port,
|
||||||
|
:use_ssl => uri.scheme == 'https',
|
||||||
|
open_timeout: 60,read_timeout: 60,
|
||||||
|
verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
|
||||||
|
req = Net::HTTP::Get.new(uri)
|
||||||
|
http.request(req)
|
||||||
|
end
|
||||||
if res.code == "302" || res.code == "301"
|
if res.code == "302" || res.code == "301"
|
||||||
location = res['Location']
|
location = res['Location']
|
||||||
cookie = res['Set-Cookie']
|
cookie = res['Set-Cookie']
|
||||||
headers = {
|
|
||||||
'Cookie' => cookie,
|
|
||||||
}
|
|
||||||
if location[0] == "/"
|
if location[0] == "/"
|
||||||
uri = URI.parse("#{uri.scheme}://#{uri.host}#{location}")
|
uri = URI.parse("#{uri.scheme}://#{uri.host}#{location}")
|
||||||
else
|
else
|
||||||
uri = URI.parse(location)
|
uri = URI.parse(location)
|
||||||
end
|
end
|
||||||
res = Net::HTTP.get_response(uri,nil,headers)
|
res = Net::HTTP.start(uri.host, uri.port,
|
||||||
|
:use_ssl => uri.scheme == 'https',
|
||||||
|
open_timeout: 60,read_timeout: 60,
|
||||||
|
verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
|
||||||
|
req = Net::HTTP::Get.new(uri)
|
||||||
|
req['Cookie'] = cookie
|
||||||
|
http.request(req)
|
||||||
|
end
|
||||||
return res.body
|
return res.body
|
||||||
else
|
else
|
||||||
return res.body
|
return res.body
|
||||||
|
|
Loading…
Reference in New Issue