Fix request bug.

This commit is contained in:
BoHung Chiu 2022-05-10 10:03:39 +08:00
parent b162819874
commit e961a3c26d
1 changed files with 19 additions and 4 deletions

View File

@ -53,6 +53,21 @@ class Admin::AnnouncementsController < OrbitAdminController
@table_feed_fields = ["announcement.time", "announcement.comment", "announcement.account","ip","is_hidden"]
@comments = @bulletin.bulletin_comments.reverse rescue []
end
def http_request(http, request)
response = http.request(request)
if response.code.to_i == 301 || response.code.to_i == 302
location = response["location"]
new_uri = URI(location)
http = Net::HTTP.new(new_uri.host, new_uri.port)
if location.include?('https')
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
request.instance_variable_set(:@path, new_uri.path)
response = http_request(http, request)
end
response
end
def index
Bulletin.remove_expired_status
@tags = @module_app.tags
@ -329,7 +344,7 @@ class Admin::AnnouncementsController < OrbitAdminController
if remote_url.include?('https')
http_req.use_ssl = true
end
response = http_req.request(request)
response = http_request( http_req , request )
end
end
end
@ -437,7 +452,7 @@ class Admin::AnnouncementsController < OrbitAdminController
if remote_url.include?('https')
http_req.use_ssl = true
end
response = http_req.request(request)
response = http_request( http_req , request )
end
end
end
@ -465,7 +480,7 @@ class Admin::AnnouncementsController < OrbitAdminController
if remote_url.include?('https')
http_req.use_ssl = true
end
response = http_req.request(request)
response = http_request( http_req , request )
end
end
end
@ -495,7 +510,7 @@ class Admin::AnnouncementsController < OrbitAdminController
if remote_url.include?('https')
http_req.use_ssl = true
end
response = http_req.request(request)
response = http_request( http_req , request )
end
end
end