Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "curl: alert on 301 redirect" #8117

Merged
merged 1 commit into from Jul 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 7 additions & 12 deletions Library/Homebrew/utils/curl.rb
Expand Up @@ -127,8 +127,6 @@ 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
Expand Down Expand Up @@ -205,23 +203,20 @@ 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],
file_hash: output_hash,
file: output,
url: url,
final_url: final_url,
status: status_code,
etag: headers[%r{ETag: ([wW]/)?"(([^"]|\\")*)"}, 2],
content_length: headers[/Content-Length: (\d+)/, 1],
file_hash: output_hash,
file: output,
}
ensure
file.unlink
Expand Down