Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with LibCURL's new generator script #134

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/Curl/Curl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ using LibCURL
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

using NetworkOptions
using Base: preserve_handle, unpreserve_handle

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

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

# CEnum is no longer Integer in LibCURL.jl
setopt(easy::Easy, option::CURLoption, value) = setopt(easy, Int(option), value)
setopt(multi::Multi, option::CURLMoption, value) = setopt(multi, Int(option), value)
Base.zero(::CURLcode) = CURLE_OK
Base.zero(::CURLMcode) = CURLM_OK

end # module
4 changes: 2 additions & 2 deletions src/Downloads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function download(
downloader = downloader,
)
status_ok(response.proto, response.status) && return output
throw(RequestError(url, Curl.CURLE_OK, "", response))
throw(RequestError(url, Int(Curl.CURLE_OK), "", response))
end
end

Expand Down Expand Up @@ -365,7 +365,7 @@ function request(
response = Response(get_response_info(easy)...)
easy.code == Curl.CURLE_OK && return response
message = get_curl_errstr(easy)
response = RequestError(url, easy.code, message, response)
response = RequestError(url, Int(easy.code), message, response)
throw && Base.throw(response)
end
end
Expand Down
4 changes: 2 additions & 2 deletions 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 == Int(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 Expand Up @@ -414,7 +414,7 @@ include("setup.jl")
@testset "bad TLS is rejected" for url in urls
resp = request(url, throw=false)
@test resp isa RequestError
@test resp.code == Curl.CURLE_PEER_FAILED_VERIFICATION
@test resp.code == Int(Curl.CURLE_PEER_FAILED_VERIFICATION)
end
@testset "easy hook work-around" begin
local url
Expand Down