From 193060fd2f90c8aad33b96ef067be87c89321923 Mon Sep 17 00:00:00 2001 From: melonedo <44501064+melonedo@users.noreply.github.com> Date: Wed, 21 Jul 2021 17:18:34 +0800 Subject: [PATCH] Sync with LibCURL's new generated wrapper Ref https://github.com/JuliaWeb/LibCURL.jl/pull/102 --- src/Curl/Curl.jl | 12 ++++++++---- src/Curl/utils.jl | 2 +- src/Downloads.jl | 2 +- test/runtests.jl | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Curl/Curl.jl b/src/Curl/Curl.jl index e4f5171..a46411f 100644 --- a/src/Curl/Curl.jl +++ b/src/Curl/Curl.jl @@ -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 @@ -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 diff --git a/src/Curl/utils.jl b/src/Curl/utils.jl index ccae87f..5234291 100644 --- a/src/Curl/utils.jl +++ b/src/Curl/utils.jl @@ -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 diff --git a/src/Downloads.jl b/src/Downloads.jl index 5e07a74..532ead7 100644 --- a/src/Downloads.jl +++ b/src/Downloads.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index fd4bb20..260cec0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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"