Skip to content

Commit

Permalink
add extra headers args
Browse files Browse the repository at this point in the history
  • Loading branch information
oxinabox authored Aug 7, 2018
1 parent 6b9ae64 commit a6b4dba
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/download.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function determine_file(path, resp)
end

"""
download(url, [local_path]; update_period=0.5)
download(url, [local_path], [headers]; update_period=0.5, kw...)
Similar to `Base.download` this downloads a file, returning the filename.
If the `local_path`:
Expand All @@ -85,12 +85,13 @@ from the rules of the HTTP.
- `update_period` controls how often (in seconds) to report the progress.
- set to `Inf` to disable reporting
- `headers` specifies headers to be used for the HTTP GET request
- any additional keyword args (`kw...`) are passed on to the HTTP request.
"""
function download(url::AbstractString, local_path=nothing; update_period=0.5)
function download(url::AbstractString, local_path=nothing, headers=Header[]; update_period=0.5; kw...)
@debug 1 "downloading $url"
local file
HTTP.open("GET", url) do stream
HTTP.open("GET", url, headers; kw..) do stream
resp = startread(stream)
file = determine_file(local_path, resp)
total_bytes = parse(Float64, getkv(resp.headers, "Content-Length", "NaN"))
Expand Down

0 comments on commit a6b4dba

Please sign in to comment.