From 555ce9a5b01dd80c22da212c712c5e6a7c50847b Mon Sep 17 00:00:00 2001 From: "alejandro.alvarez.acero" Date: Mon, 17 Apr 2023 11:47:33 +0200 Subject: [PATCH] Merge URL `:header` with `:headers`. --- Library/Homebrew/download_strategy.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index cd57614bd1..e3c1ae140b 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -378,6 +378,14 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy super @try_partial = true @mirrors = meta.fetch(:mirrors, []) + + # Merge `:header` with `:headers`. + if (header = meta.delete(:header)) + meta[:headers] ||= [] + meta[:headers] << header + end + + super end # Download and cache the file at {#cached_location}. @@ -543,7 +551,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy args += ["--user", meta.fetch(:user)] if meta.key?(:user) - args += [meta[:header], meta[:headers]].flatten.compact.flat_map { |h| ["--header", h.strip] } + args += meta.fetch(:headers, []).flat_map { |h| ["--header", h.strip] } if meta[:insecure] unless @insecure_warning_shown