Skip to content

Commit 193060f

Browse files
committed
Sync with LibCURL's new generated wrapper
Ref JuliaWeb/LibCURL.jl#102
1 parent 4fec7f1 commit 193060f

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/Curl/Curl.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ using LibCURL: curl_off_t
3030
# not exported: https://github.com/JuliaWeb/LibCURL.jl/issues/87
3131

3232
# constants that LibCURL should have but doesn't
33-
const CURLE_PEER_FAILED_VERIFICATION = 60
34-
const CURLSSLOPT_REVOKE_BEST_EFFORT = 1 << 3
33+
if Integer(LibCURL.CURLE_PEER_FAILED_VERIFICATION) != 60
34+
const CURLE_PEER_FAILED_VERIFICATION = 60
35+
end
36+
if !@isdefined CURLSSLOPT_REVOKE_BEST_EFFORT
37+
const CURLSSLOPT_REVOKE_BEST_EFFORT = 1 << 3
38+
end
3539

3640
using NetworkOptions
3741
using Base: preserve_handle, unpreserve_handle
@@ -67,9 +71,9 @@ function with_handle(f, handle::Union{Multi, Easy})
6771
end
6872
end
6973

70-
setopt(easy::Easy, option::Integer, value) =
74+
setopt(easy::Easy, option::CURLoption, value) =
7175
@check curl_easy_setopt(easy.handle, option, value)
72-
setopt(multi::Multi, option::Integer, value) =
76+
setopt(multi::Multi, option::CURLMoption, value) =
7377
@check curl_multi_setopt(multi.handle, option, value)
7478

7579
end # module

src/Curl/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function check(ex::Expr, lock::Bool)
3333
end
3434
quote
3535
r = $ex
36-
iszero(r) || @async @error($prefix * string(r))
36+
iszero(Integer(r)) || @async @error($prefix * string(r))
3737
r
3838
end
3939
end

src/Downloads.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ in which case both the inner and outer code and message may be of interest.
124124
"""
125125
struct RequestError <: Exception
126126
url :: String # original URL
127-
code :: Int
127+
code :: Curl.CURLcode
128128
message :: String
129129
response :: Response
130130
end

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ include("setup.jl")
275275

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

0 commit comments

Comments
 (0)