Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当verbose=TRUE时从curl包捕获消息_R - Fatal编程技术网

当verbose=TRUE时从curl包捕获消息

当verbose=TRUE时从curl包捕获消息,r,R,我需要捕获从各种curl函数输出的详细消息 这里有一个例子 testCurlCalls <- function(x){ ## Setting up data vendor calls in parallel ############################### out <<- list() dbout <<- list() # This is function, function which will be run if data ve

我需要捕获从各种curl函数输出的详细消息

这里有一个例子

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})
  )

}

testcalls尝试了它。你不尝试另一个软件包吗?我使用curl同时运行多个调用,因此我们需要一些与curl兼容的东西。你不尝试另一个软件包吗?我使用curl同时运行多个调用,因此我们需要一些与curl一起工作的东西
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