mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Merge pull request #8076 from dtrodrigues/301-redirect
curl: alert on 301 redirect
This commit is contained in:
commit
c42bcf7398
@ -127,6 +127,8 @@ def curl_check_http_content(url, user_agents: [:default], check_content: false,
|
||||
return "The URL #{url} is not reachable"
|
||||
end
|
||||
|
||||
return "#{url} permanently redirects to #{details[:permanent_redirect]}" if url != details[:permanent_redirect]
|
||||
|
||||
unless http_status_ok?(details[:status])
|
||||
return "The URL #{url} is not reachable (HTTP status code #{details[:status]})"
|
||||
end
|
||||
@ -203,15 +205,18 @@ def curl_http_content_headers_and_checksum(url, hash_needed: false, user_agent:
|
||||
status_code = headers[%r{HTTP/.* (\d+)}, 1]
|
||||
location = headers[/^Location:\s*(.*)$/i, 1]
|
||||
final_url = location.chomp if location
|
||||
permanent_redirect = location.chomp if status_code == "301"
|
||||
end
|
||||
|
||||
output_hash = Digest::SHA256.file(file.path) if hash_needed
|
||||
|
||||
final_url ||= url
|
||||
permanent_redirect ||= url
|
||||
|
||||
{
|
||||
url: url,
|
||||
final_url: final_url,
|
||||
permanent_redirect: permanent_redirect,
|
||||
status: status_code,
|
||||
etag: headers[%r{ETag: ([wW]/)?"(([^"]|\\")*)"}, 2],
|
||||
content_length: headers[/Content-Length: (\d+)/, 1],
|
||||
|
Loading…
x
Reference in New Issue
Block a user