Skip to content

Commit 3ed0f08

Browse files
authored
Document how to bypass the 20-second timeout (#222)
1 parent f97c72f commit 3ed0f08

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

src/Downloads.jl

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ const DOWNLOAD_LOCK = ReentrantLock()
6565
const DOWNLOADER = Ref{Union{Downloader, Nothing}}(nothing)
6666

6767
"""
68-
`EASY_HOOK` is a modifable global hook to used as the default `easy_hook` on
69-
new `Downloader` objects. This supplies a mechanism to set options for the
68+
`EASY_HOOK` is a modifable global hook to used as the default `easy_hook` on
69+
new `Downloader` objects. This supplies a mechanism to set options for the
7070
`Downloader` via `Curl.setopt`
7171
72-
It is expected to be function taking two arguments: an `Easy` struct and an
73-
`info` NamedTuple with names `url`, `method` and `headers`.
72+
It is expected to be function taking two arguments: an `Easy` struct and an
73+
`info` NamedTuple with names `url`, `method` and `headers`.
7474
"""
7575
const EASY_HOOK = Ref{Union{Function, Nothing}}(nothing)
7676

@@ -205,9 +205,11 @@ If the `headers` keyword argument is provided, it must be a vector or dictionary
205205
whose elements are all pairs of strings. These pairs are passed as headers when
206206
downloading URLs with protocols that supports them, such as HTTP/S.
207207
208-
The `timeout` keyword argument specifies a timeout for the download in seconds,
209-
with a resolution of milliseconds. By default no timeout is set, but this can
210-
also be explicitly requested by passing a timeout value of `Inf`.
208+
The `timeout` keyword argument specifies a timeout for the download to complete in
209+
seconds, with a resolution of milliseconds. By default no timeout is set, but this
210+
can also be explicitly requested by passing a timeout value of `Inf`. Separately,
211+
if 20 seconds elapse without receiving any data, the download will timeout. See
212+
extended help for how to disable this timeout.
211213
212214
If the `progress` keyword argument is provided, it must be a callback function
213215
which will be called whenever there are updates about the size and status of the
@@ -226,6 +228,20 @@ verbose option is ignored and instead the data that would have been printed to
226228
The `type` argument indicates what kind of event has occurred, and is one of:
227229
`TEXT`, `HEADER IN`, `HEADER OUT`, `DATA IN`, `DATA OUT`, `SSL DATA IN` or `SSL
228230
DATA OUT`. The `message` argument is the description of the debug event.
231+
232+
## Extended Help
233+
234+
For further customization, use a [`Downloader`](@ref) and
235+
[`easy_hook`s](https://github.com/JuliaLang/Downloads.jl#mutual-tls-using-downloads).
236+
For example, to disable the 20 second timeout when no data is received, you may
237+
use the following:
238+
239+
```jl
240+
downloader = Downloads.Downloader()
241+
downloader.easy_hook = (easy, info) -> Downloads.Curl.setopt(easy, Downloads.Curl.CURLOPT_LOW_SPEED_TIME, 0)
242+
243+
Downloads.download("https://httpbingo.julialang.org/delay/30"; downloader)
244+
```
229245
"""
230246
function download(
231247
url :: AbstractString,
@@ -435,7 +451,7 @@ end
435451
"""
436452
default_downloader!(
437453
downloader = <none>
438-
)
454+
)
439455
440456
downloader :: Downloader
441457

0 commit comments

Comments
 (0)