Access information about a CURL request
getCurlInfo.RdThis function provides access to data about a previously
executed CURL request that is accessible via a
CURLHandle object.
This means, of course, that one must have access to the CURLHandle
object.
The information one can get includes items such as the name of the
file (potentially containing redirects), download time,
See getCurlInfoConstants for the names of the possible fields.
Arguments
- curl
the
CURLHandleobject used to perform the request. This is a reference to an opaque internal C-level data structure that is provided and used by libcurl to make a request.- which
identifiers for the elements of interest. These can be specified by integer value or by name. The names are matched against those in the
getCurlInfoConstants
.
Value
A named list whose elements correspond to the requested fields. The names are expanded to match the names of these fields and the values are either strings or integer values.
References
Curl homepage https://curl.se/
Examples
tryCatch(withAutoprint({
curl = getCurlHandle()
txt = getURL("https://r-project.org", curl = curl)
getCurlInfo(curl)
rm(curl) # release the curl!
}), GenericCurlError = identity)
#> > curl = getCurlHandle()
#> > txt = getURL("https://r-project.org", curl = curl)
#> > getCurlInfo(curl)
#> $effective.url
#> [1] "https://www.r-project.org/"
#>
#> $response.code
#> [1] 200
#>
#> $total.time
#> [1] 1.255839
#>
#> $namelookup.time
#> [1] 0.609958
#>
#> $connect.time
#> [1] 0.820561
#>
#> $pretransfer.time
#> [1] 1.043036
#>
#> $size.upload
#> [1] 0
#>
#> $size.download
#> [1] 6445
#>
#> $speed.download
#> [1] 5132
#>
#> $speed.upload
#> [1] 0
#>
#> $header.size
#> [1] 406
#>
#> $request.size
#> [1] 137
#>
#> $ssl.verifyresult
#> [1] 0
#>
#> $filetime
#> [1] -1
#>
#> $content.length.download
#> [1] 6445
#>
#> $content.length.upload
#> [1] 0
#>
#> $starttransfer.time
#> [1] 1.254662
#>
#> $content.type
#> [1] "text/html"
#>
#> $redirect.time
#> [1] 0.836649
#>
#> $redirect.count
#> [1] 1
#>
#> $private
#> NULL
#>
#> $http.connectcode
#> [1] 0
#>
#> $httpauth.avail
#> [1] 0
#>
#> $proxyauth.avail
#> [1] 0
#>
#> $os.errno
#> [1] 0
#>
#> $num.connects
#> [1] 2
#>
#> $ssl.engines
#> [1] "dynamic"
#>
#> $cookielist
#> character(0)
#>
#> $lastsocket
#> [1] 26
#>
#> $ftp.entry.path
#> NULL
#>
#> $redirect.url
#> NULL
#>
#> $primary.ip
#> [1] "137.208.57.37"
#>
#> $appconnect.time
#> [1] 1.042702
#>
#> $certinfo
#> list()
#>
#> $condition.unmet
#> [1] 0
#>
#> > rm(curl)