Skip to content

Commit 667162d

Browse files
committed
Sync with LibCURL's new generated wrapper
Ref JuliaWeb/LibCURL.jl#102
1 parent 5d00bdd commit 667162d

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/Curl/Curl.jl

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

32-
# constants that LibCURL should have but doesn't
33-
const CURLE_PEER_FAILED_VERIFICATION = 60
34-
const CURLSSLOPT_REVOKE_BEST_EFFORT = 1 << 3
35-
3632
using NetworkOptions
3733
using Base: preserve_handle, unpreserve_handle
3834

@@ -68,8 +64,14 @@ function with_handle(f, handle::Union{Multi, Easy})
6864
end
6965

7066
setopt(easy::Easy, option::Integer, value) =
71-
@check curl_easy_setopt(easy.handle, option, value)
67+
@check curl_easy_setopt(easy.handle, CURLoption(option), value)
7268
setopt(multi::Multi, option::Integer, value) =
73-
@check curl_multi_setopt(multi.handle, option, value)
69+
@check curl_multi_setopt(multi.handle, CURLMoption(option), value)
70+
71+
# CEnum is no longer Integer in LibCURL.jl
72+
setopt(easy::Easy, option::CURLoption, value) = setopt(easy, Int(option), value)
73+
setopt(multi::Multi, option::CURLMoption, value) = setopt(multi, Int(option), value)
74+
Base.zero(::CURLcode) = CURLE_OK
75+
Base.zero(::CURLMcode) = CURLM_OK
7476

7577
end # module

src/Downloads.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ function download(
230230
downloader = downloader,
231231
)
232232
status_ok(response.proto, response.status) && return output
233-
throw(RequestError(url, Curl.CURLE_OK, "", response))
233+
throw(RequestError(url, Int(Curl.CURLE_OK), "", response))
234234
end
235235
end
236236

@@ -365,7 +365,7 @@ function request(
365365
response = Response(get_response_info(easy)...)
366366
easy.code == Curl.CURLE_OK && return response
367367
message = get_curl_errstr(easy)
368-
response = RequestError(url, easy.code, message, response)
368+
response = RequestError(url, Int(easy.code), message, response)
369369
throw && Base.throw(response)
370370
end
371371
end

test/runtests.jl

Lines changed: 2 additions & 2 deletions
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 == Int(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"
@@ -414,7 +414,7 @@ include("setup.jl")
414414
@testset "bad TLS is rejected" for url in urls
415415
resp = request(url, throw=false)
416416
@test resp isa RequestError
417-
@test resp.code == Curl.CURLE_PEER_FAILED_VERIFICATION
417+
@test resp.code == Int(Curl.CURLE_PEER_FAILED_VERIFICATION)
418418
end
419419
@testset "easy hook work-around" begin
420420
local url

0 commit comments

Comments
 (0)