diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 71db2744f9..0ee946872b 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -390,7 +390,8 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy resolved_url, _, url_time, _, is_redirection = resolve_url_basename_time_file_size(url, timeout: end_time&.remaining!) - meta[:headers].delete_if { |header| header[0].start_with?("Authorization") } if is_redirection + # Authorization is no longer valid after redirects + meta[:headers].delete_if { |header| header.first&.start_with?("Authorization") } if is_redirection fresh = if cached_location.exist? && url_time url_time <= cached_location.mtime