mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: FinalDestination's small_get method wasn't using proper request headers
This commit is contained in:
parent
aebcd56300
commit
de037da731
1 changed files with 3 additions and 7 deletions
|
@ -63,7 +63,7 @@ class FinalDestination
|
||||||
def request_headers
|
def request_headers
|
||||||
result = {
|
result = {
|
||||||
"User-Agent" => "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36",
|
"User-Agent" => "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36",
|
||||||
"Accept" => "text/html",
|
"Accept" => "*/*",
|
||||||
"Host" => @uri.hostname
|
"Host" => @uri.hostname
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,11 +76,7 @@ class FinalDestination
|
||||||
Net::HTTP.start(@uri.host, @uri.port, use_ssl: @uri.is_a?(URI::HTTPS)) do |http|
|
Net::HTTP.start(@uri.host, @uri.port, use_ssl: @uri.is_a?(URI::HTTPS)) do |http|
|
||||||
http.open_timeout = FinalDestination.connection_timeout
|
http.open_timeout = FinalDestination.connection_timeout
|
||||||
http.read_timeout = FinalDestination.connection_timeout
|
http.read_timeout = FinalDestination.connection_timeout
|
||||||
|
http.request_get(@uri.request_uri, headers)
|
||||||
request = Net::HTTP::Get.new(@uri.request_uri, headers)
|
|
||||||
http.request(request) do |response|
|
|
||||||
return response
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -125,7 +121,7 @@ class FinalDestination
|
||||||
@status = :resolved
|
@status = :resolved
|
||||||
return @uri
|
return @uri
|
||||||
when 405, 406, 409, 501
|
when 405, 406, 409, 501
|
||||||
get_response = small_get(headers)
|
get_response = small_get(request_headers)
|
||||||
|
|
||||||
response_status = get_response.code.to_i
|
response_status = get_response.code.to_i
|
||||||
if response_status == 200
|
if response_status == 200
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue