diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 166a1b3340469..0cf98d5317e4e 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -421,7 +421,7 @@ def _curl_args args += ["--user", meta.fetch(:user)] if meta.key?(:user) - args += ["--header", meta.fetch(:header)] if meta.key?(:header) + args += [meta[:header], meta[:headers]].flatten.compact.flat_map { |h| ["--header", h.strip] } args end diff --git a/Library/Homebrew/test/download_strategies_spec.rb b/Library/Homebrew/test/download_strategies_spec.rb index e8b456d226c07..f24857652eecd 100644 --- a/Library/Homebrew/test/download_strategies_spec.rb +++ b/Library/Homebrew/test/download_strategies_spec.rb @@ -241,6 +241,21 @@ def setup_git_repo subject.fetch end end + + context "with headers set" do + alias_matcher :a_string_matching, :match + + let(:specs) { { headers: ["foo", "bar"] } } + + it "adds the appropriate curl args" do + expect(subject).to receive(:system_command!) { |*, args:, **| + expect(args.each_cons(2).to_a).to include(["--header", "foo"]) + expect(args.each_cons(2).to_a).to include(["--header", "bar"]) + } + + subject.fetch + end + end end describe "#cached_location" do