HttpClient

0th

Percentile

HTTP client

HTTP client

Keywords
datasets
Arguments
url
(character) A url. One of url or handle required.
opts
(list) curl options
handle
A handle
Details

Methods

Aliases
  • HttpClient
Examples
## Not run: 
# (x <- HttpClient$new(url = "https://httpbin.org"))
# x$url
# (res_get1 <- x$get('get'))
# res_get1$content
# res_get1$response_headers
# res_get1$parse()
# 
# (res_get2 <- x$get('get', query = list(hello = "world")))
# res_get2$parse()
# library("jsonlite")
# jsonlite::fromJSON(res_get2$parse())
# 
# # post request
# (res_post <- x$post('post', body = list(hello = "world")))
# 
# ## empty body request
# x$post('post')
# 
# # put request
# (res_put <- x$put('put'))
# 
# # delete request
# (res_delete <- x$delete('delete'))
# 
# # patch request
# (res_patch <- x$patch('patch'))
# 
# # head request
# (res_head <- x$head())
# 
# # set options on client initialization
# (res <- HttpClient$new(
#   url = "https://httpbin.org",
#   opts = list(
#     verbose = TRUE,
#     useragent = "hello world"
#   )
# ))
# res$opts
# res$get('get')
# 
# # set headers
# (res <- HttpClient$new(
#   url = "https://httpbin.org",
#   opts = list(
#     verbose = TRUE
#   ),
#   headers = list(
#     a = "stuff",
#     b = "things"
#   )
# ))
# res$headers
# # reassign header value
# res$headers$a <- "that"
# # define new header
# res$headers$c <- "what"
# # request
# res$get('get')
# 
# 
# # handles - pass in your own handle
# h <- handle("https://httpbin.org")
# (res <- HttpClient$new(handle = h))
# out <- res$get("get")
# ## End(Not run)
Documentation reproduced from package crul, version 0.1.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.