Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Downloads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ function grace_ms(grace::Real)
grace <= typemax(UInt64) ÷ 1000 ? round(UInt64, 1000*grace) : typemax(UInt64)
end

function easy_hook(downloader::Downloader, easy::Easy, info::NamedTuple)
downloader.easy_hook !== nothing && downloader.easy_hook(easy, info)
end

get_ca_roots() = Curl.SYSTEM_SSL ? ca_roots() : ca_roots_path()

function set_ca_roots(downloader::Downloader, easy::Easy)
Expand Down Expand Up @@ -289,6 +285,7 @@ function request(
verbose :: Bool = false,
throw :: Bool = true,
downloader :: Union{Downloader, Nothing} = nothing,
easy_hook :: Union{Function, Nothing} = nothing
) :: Union{Response, RequestError}
lock(DOWNLOAD_LOCK) do
yield() # let other downloads finish
Expand Down Expand Up @@ -338,8 +335,11 @@ function request(
method !== nothing && set_method(easy, method)
progress !== nothing && enable_progress(easy)
set_ca_roots(downloader, easy)

# Apply user-defined customizations to the Curl easy handle
info = (url = url, method = method, headers = headers)
easy_hook(downloader, easy, info)
downloader.easy_hook !== nothing && downloader.easy_hook(easy, info)
easy_hook !== nothing && easy_hook(easy)

# do the request
add_handle(downloader.multi, easy)
Expand Down