Skip to content

Commit

Permalink
Add headers option on RemoteFile/Http
Browse files Browse the repository at this point in the history
- Add an option :headers key for the caller to provide custom headers
  • Loading branch information
wilmarvh committed Jul 4, 2019
1 parent bc9e262 commit 5e61dca
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
cocoapods-downloader (1.2.2)
cocoapods-downloader (1.2.3)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion lib/cocoapods-downloader/gem_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module Downloader
# @return [String] Downloader’s version, following
# [semver](http://semver.org).
#
VERSION = '1.2.2'.freeze
VERSION = '1.2.3'.freeze
end
end
9 changes: 8 additions & 1 deletion lib/cocoapods-downloader/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ class Http < RemoteFile
executable :curl

def download_file(full_filename)
curl! '-f', '-L', '-o', full_filename, url, '--create-dirs', '--netrc-optional', '--retry', '2'
parameters = ['-f', '-L', '-o', full_filename, url, '--create-dirs', '--netrc-optional', '--retry', '2']

headers.each do |h|
parameters << '-H'
parameters << h
end unless headers.nil?

curl! parameters
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion lib/cocoapods-downloader/remote_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Pod
module Downloader
class RemoteFile < Base
def self.options
[:type, :flatten, :sha1, :sha256]
[:type, :flatten, :sha1, :sha256, :headers]
end

class UnsupportedFileTypeError < StandardError; end
Expand Down Expand Up @@ -35,6 +35,10 @@ def type
end
end

def headers
options[:headers]
end

# @note The archive is flattened if it contains only one folder and its
# extension is either `tgz`, `tar`, `tbz` or the options specify
# it.
Expand Down

0 comments on commit 5e61dca

Please sign in to comment.