download_strategy: fix error when using custom headers with a redirect
This commit is contained in:
		
							parent
							
								
									f026dd21c1
								
							
						
					
					
						commit
						de15cd6420
					
				@ -391,7 +391,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
 | 
			
		||||
      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
 | 
			
		||||
@ -569,7 +569,7 @@ class CurlGitHubPackagesDownloadStrategy < CurlDownloadStrategy
 | 
			
		||||
    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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user