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

download_strategy: fix error when using custom headers with a redirect #11871

Merged
merged 1 commit into from Aug 18, 2021
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
4 changes: 2 additions & 2 deletions Library/Homebrew/download_strategy.rb
Expand Up @@ -391,7 +391,7 @@ def fetch(timeout: nil)
resolved_url, _, url_time, _, is_redirection =
resolve_url_basename_time_file_size(url, timeout: end_time&.remaining!)
# Authorization is no longer valid after redirects
meta[:headers]&.delete_if { |header| header.first&.start_with?("Authorization") } if is_redirection
meta[:headers]&.delete_if { |header| header.start_with?("Authorization") } if is_redirection

fresh = if cached_location.exist? && url_time
url_time <= cached_location.mtime
Expand Down Expand Up @@ -569,7 +569,7 @@ def initialize(url, name, version, **meta)
meta ||= {}
meta[:headers] ||= []
token = Homebrew::EnvConfig.artifact_domain ? Homebrew::EnvConfig.docker_registry_token : "QQ=="
meta[:headers] << ["Authorization: Bearer #{token}"] if token.present?
meta[:headers] << "Authorization: Bearer #{token}" if token.present?
super(url, name, version, meta)
end

Expand Down