Merge pull request #7144 from spaceapegames/master

Add headers option to URLs in forumlas
This commit is contained in:
Mike McQuaid 2020-04-01 16:22:35 +01:00 committed by GitHub
commit c0dca271ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -421,7 +421,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
args += ["--user", meta.fetch(:user)] if meta.key?(:user) 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 args
end end

View File

@ -241,6 +241,21 @@ describe CurlDownloadStrategy do
subject.fetch subject.fetch
end end
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 end
describe "#cached_location" do describe "#cached_location" do