1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#' curl options
#'
#' With the `opts` parameter you can pass in various
#' curl options, including user agent string, whether to get verbose
#' curl output or not, setting a timeout for requests, and more. See
#' [curl::curl_options()] for all the options you can use. Note that
#' you need to give curl options exactly as given in
#' [curl::curl_options()].
#'
#' @name curl-options
#' @aliases user-agent verbose timeout
#'
#' @examples \dontrun{
#' url <- "https://httpbin.org"
#'
#' # set curl options on client initialization
#' (res <- HttpClient$new(url = url, opts = list(verbose = TRUE)))
#' res$opts
#' res$get('get')
#'
#' # or set curl options when performing HTTP operation
#' (res <- HttpClient$new(url = url))
#' res$get('get', verbose = TRUE)
#' res$get('get', stuff = "things")
#'
#' # set a timeout
#' (res <- HttpClient$new(url = url, opts = list(timeout_ms = 1)))
#' # res$get('get')
#'
#' # set user agent either as a header or an option
#' HttpClient$new(url = url,
#' headers = list(`User-Agent` = "hello world"),
#' opts = list(verbose = TRUE)
#' )$get('get')
#'
#' HttpClient$new(url = url,
#' opts = list(verbose = TRUE, useragent = "hello world")
#' )$get('get')
#'
#' # You can also set custom debug function via the verbose
#' # parameter when calling `$new()`
#' res <- HttpClient$new(url, verbose=curl_verbose())
#' res
#' res$get("get")
#' res <- HttpClient$new(url, verbose=curl_verbose(data_in=TRUE))
#' res$get("get")
#' res <- HttpClient$new(url, verbose=curl_verbose(info=TRUE))
#' res$get("get")
#' }
NULL
|