@@ -10,6 +10,24 @@ function curl_write_cb(curlbuf::Ptr{Cvoid}, s::Csize_t, n::Csize_t, p_ctxt::Ptr{
1010 return sz:: Csize_t
1111end
1212
13+ # Setup the callback function to collect debug information
14+ const infotype_str = Dict (
15+ 0 => " CURLINFO_TEXT" ,
16+ 1 => " CURLINFO_HEADER_IN" ,
17+ 2 => " CURLINFO_HEADER_OUT" ,
18+ 3 => " CURLINFO_DATA_IN" ,
19+ 4 => " CURLINFO_DATA_OUT" ,
20+ 5 => " CURLINFO_SSL_DATA_IN" ,
21+ 6 => " CURLINFO_SSL_DATA_OUT" ,
22+ )
23+
24+ function curl_debug_cb (handle:: Ptr{Cvoid} , type:: Cint , data:: Ptr{Cvoid} , sz:: Csize_t , clientp:: Ptr{Cvoid} )
25+ debug_buffer = unsafe_pointer_to_objref (clientp):: IOBuffer
26+ data = UInt8[unsafe_load (reinterpret (Ptr{Cuchar}, data), n) for n in 1 : sz]
27+ println (debug_buffer, " $(infotype_str[type]) \" $(String (data)) \" " )
28+ return Cint (0 )
29+ end
30+
1331@testset " SSL verify" begin
1432 # Set up the write function to consume the curl output so we don't see it in the
1533 # test output
2745 curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 1 )
2846 curl_easy_setopt (curl, CURLOPT_CAINFO, LibCURL. cacert)
2947
30- @testset " SSL Success" begin
31- res = curl_easy_perform (curl)
32- @test res == CURLE_OK
33- end
48+ # For debugging -- we see that `res ≠ CURLE_OK` below and want to know why
49+ curl_easy_setopt (curl, CURLOPT_VERBOSE, 1 )
50+ c_curl_debug_cb = @cfunction (
51+ curl_debug_cb,
52+ Cint,
53+ (Ptr{Cvoid}, Cint, Ptr{Cvoid}, Csize_t, Ptr{Cvoid})
54+ )
55+ debug_buffer = IOBuffer ()
56+ GC. @preserve debug_buffer begin
57+ curl_easy_setopt (curl, CURLOPT_DEBUGFUNCTION, c_curl_debug_cb)
58+ curl_easy_setopt (curl, CURLOPT_DEBUGDATA, pointer_from_objref (debug_buffer))
3459
60+ @testset " SSL Success" begin
61+ res = curl_easy_perform (curl)
62+ if ! (res == CURLE_OK)
63+ println (" CURL debug output:\n " )
64+ print (takestring! (debug_buffer))
65+ end
66+ @test res == CURLE_OK
67+ end
68+ end
3569end
3670
3771curl_easy_cleanup (curl)
0 commit comments