Skip to content

Commit

Permalink
add connect timeout; reinstate speed limit (#126)
Browse files Browse the repository at this point in the history
- This adds a connection timeout of 30 seconds, closing #125
- It re-instates the lower speed limit that was briefly added in #85 and
  was accidentally reverted in the following pull request (#86)

In combination, this should prevent downloads from hanging, whether
because the server is unavailable and so the connection is never
established, or because the server never sends any data after the
connection is established. This does not put an absolute timeout on
downloads since a very large download can take arbitrarily long while
still making progress.

(cherry picked from commit 84e948c)
  • Loading branch information
StefanKarpinski committed Jun 1, 2021
1 parent 7a74621 commit 140b22b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Curl/Easy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ function set_defaults(easy::Easy)
setopt(easy, CURLOPT_USERAGENT, USER_AGENT)
setopt(easy, CURLOPT_SSL_OPTIONS, CURLSSLOPT_REVOKE_BEST_EFFORT)

# prevent downloads that hang forever:
# - timeout no response on connect (more than 30s)
# - if server transmits nothing for 20s, bail out
setopt(easy, CURLOPT_CONNECTTIMEOUT, 30)
setopt(easy, CURLOPT_LOW_SPEED_TIME, 20)
setopt(easy, CURLOPT_LOW_SPEED_LIMIT, 1)

# ssh-related options
setopt(easy, CURLOPT_SSH_PRIVATE_KEYFILE, ssh_key_path())
setopt(easy, CURLOPT_SSH_PUBLIC_KEYFILE, ssh_pub_key_path())
Expand Down

0 comments on commit 140b22b

Please sign in to comment.