I need to capture the verbose messages output from various curl functions.
Here is an example
testCurlCalls <- function(x){
## Setting up data vendor calls in parallel
###############################
out <<- list()
dbout <<- list()
# This is function, function which will be run if data vendor call is successful
complete = function(res){
# cat("Request done! Status:", res$status, "\n")
out <<- c(out, list(res))
}
error_out <<- list()
error = function(res){
# cat("Request done! Status:", res$status, "\n")
error_out <<- c(error_out, list(res))
}
h1 <- new_handle(url = "https://httpbin.org/get", verbose = TRUE)
handle_setopt(h1, customrequest = "GET")
handle_setform(h1, a = "1", b = "2.1")
multi_add(h1, done = complete, fail = error)
result <- multi_run(timeout = 20)
list(
result = result
,status_codes = sapply(out, function(x){x$status_code})
)
}
When running the function the messages print out in the console
testCurlCalls()
#* Found bundle for host httpbin.org: 0x1023ae750
#* Re-using existing connection! (#6) with host httpbin.org
#* Connected to httpbin.org (23.22.14.18) port 443 (#6)
#> GET /get HTTP/1.1
#Host: httpbin.org
#User-Agent: r/curl/jeroen
#Accept: */*
#Accept-Encoding: gzip, deflate
#Content-Length: 230
#Expect: 100-continue
#Content-Type: multipart/form-data; boundary=------------------------932f59dc122a07ac
#< HTTP/1.1 100 Continue
#< HTTP/1.1 200 OK
#< Server: nginx
#< Date: Fri, 24 Feb 2017 02:16:35 GMT
#< Content-Type: application/json
#< Content-Length: 355
#< Connection: keep-alive
#< Access-Control-Allow-Origin: *
#< Access-Control-Allow-Credentials: true
#<
#* Connection #6 to host httpbin.org left intact
#$result
#$result$success
#[1] 1
#
#$result$error
#[1] 0
#
#$result$pending
#[1] 0
#
#
#$status_codes
#[1] 200
but I cannot seem to figure out how to capture the messages.