Examples for 'curl::handle'


Create and configure a curl handle

Aliases: handle new_handle handle_setopt handle_setheaders handle_getheaders handle_getcustom handle_setform handle_reset handle_data

Keywords:

### ** Examples

h <- new_handle()
handle_setopt(h, customrequest = "PUT")
handle_setform(h, a = "1", b = "2")
r <- curl_fetch_memory("https://hb.cran.dev/put", h)
cat(rawToChar(r$content))
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {
    "a": "1", 
    "b": "2"
  }, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "gzip, br", 
    "Cdn-Loop": "cloudflare; loops=1", 
    "Cf-Connecting-Ip": "130.216.254.224", 
    "Cf-Ipcountry": "NZ", 
    "Cf-Ray": "96d942a55a6e50ad-EWR", 
    "Cf-Visitor": "{\"scheme\":\"https\"}", 
    "Connection": "close", 
    "Content-Length": "228", 
    "Content-Type": "multipart/form-data; boundary=------------------------ea84c6fc4a48eb4d", 
    "Host": "httpbin:8080", 
    "User-Agent": "R (4.2.3 x86_64-pc-linux-gnu x86_64 linux-gnu) - RCloud (http://github.com/att/rcloud)"
  }, 
  "json": null, 
  "origin": "130.216.254.224", 
  "url": "https://httpbin:8080/put"
}
# Or use the list form
h <- new_handle()
handle_setopt(h, .list = list(customrequest = "PUT"))
handle_setform(h, .list = list(a = "1", b = "2"))
r <- curl_fetch_memory("https://hb.cran.dev/put", h)
cat(rawToChar(r$content))
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {
    "a": "1", 
    "b": "2"
  }, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "gzip, br", 
    "Cdn-Loop": "cloudflare; loops=1", 
    "Cf-Connecting-Ip": "130.216.254.224", 
    "Cf-Ipcountry": "NZ", 
    "Cf-Ray": "96d942a79b0d50ad-EWR", 
    "Cf-Visitor": "{\"scheme\":\"https\"}", 
    "Connection": "close", 
    "Content-Length": "228", 
    "Content-Type": "multipart/form-data; boundary=------------------------1ade31fd29d92533", 
    "Host": "httpbin:8080", 
    "User-Agent": "R (4.2.3 x86_64-pc-linux-gnu x86_64 linux-gnu) - RCloud (http://github.com/att/rcloud)"
  }, 
  "json": null, 
  "origin": "130.216.254.224", 
  "url": "https://httpbin:8080/put"
}

[Package curl version 5.2.3 Index]