fix https cert error
This commit is contained in:
parent
19807613c2
commit
782e282058
|
@ -49,19 +49,29 @@ class SiteFeed
|
|||
anns
|
||||
end
|
||||
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"
|
||||
location = res['Location']
|
||||
cookie = res['Set-Cookie']
|
||||
headers = {
|
||||
'Cookie' => cookie,
|
||||
}
|
||||
if location[0] == "/"
|
||||
uri = URI.parse("#{uri.scheme}://#{uri.host}#{location}")
|
||||
else
|
||||
uri = URI.parse(location)
|
||||
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
|
||||
else
|
||||
return res.body
|
||||
|
|
Loading…
Reference in New Issue