Skip to content

Commit

Permalink
Sync with LibCURL's new generated wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
melonedo committed Jul 21, 2021
1 parent 4fec7f1 commit 193060f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/Curl/Curl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ using LibCURL: curl_off_t
# not exported: https://github.com/JuliaWeb/LibCURL.jl/issues/87

# constants that LibCURL should have but doesn't
const CURLE_PEER_FAILED_VERIFICATION = 60
const CURLSSLOPT_REVOKE_BEST_EFFORT = 1 << 3
if Integer(LibCURL.CURLE_PEER_FAILED_VERIFICATION) != 60
const CURLE_PEER_FAILED_VERIFICATION = 60
end
if !@isdefined CURLSSLOPT_REVOKE_BEST_EFFORT
const CURLSSLOPT_REVOKE_BEST_EFFORT = 1 << 3
end

using NetworkOptions
using Base: preserve_handle, unpreserve_handle
Expand Down Expand Up @@ -67,9 +71,9 @@ function with_handle(f, handle::Union{Multi, Easy})
end
end

setopt(easy::Easy, option::Integer, value) =
setopt(easy::Easy, option::CURLoption, value) =
@check curl_easy_setopt(easy.handle, option, value)
setopt(multi::Multi, option::Integer, value) =
setopt(multi::Multi, option::CURLMoption, value) =
@check curl_multi_setopt(multi.handle, option, value)

end # module
2 changes: 1 addition & 1 deletion src/Curl/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function check(ex::Expr, lock::Bool)
end
quote
r = $ex
iszero(r) || @async @error($prefix * string(r))
iszero(Integer(r)) || @async @error($prefix * string(r))
r
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/Downloads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ in which case both the inner and outer code and message may be of interest.
"""
struct RequestError <: Exception
url :: String # original URL
code :: Int
code :: Curl.CURLcode
message :: String
response :: Response
end
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ include("setup.jl")

err = @exception download("$server/status/404")
@test err isa RequestError
@test err.code == 0 && isempty(err.message)
@test err.code == Curl.CURLE_OK && isempty(err.message)
@test err.response.status == 404
@test contains(err.response.message, r"^HTTP/\d+(?:\.\d+)?\s+404\b")
@test err.response.proto === "https"
Expand Down

0 comments on commit 193060f

Please sign in to comment.