A new minor version release (v0.7.0
) of crul is on CRAN.
Release notes: Release crul v0.7.0 · ropensci/crul · GitHub
This release includes many new features:
retry
crul
gains new retry
method on the HttpClient
class
big thanks to @hlapp for all the work on this
x <- HttpClient$new(url = "https://httpbin.org")
# retry, by default at most 3 times
x$retry("GET", path = "status/400")
# retry, but not for 404 NOT FOUND
x$retry("GET", path = "status/404", terminate_on = c(404))
verb
crul
gains new verb
method on HttpClient
, HttpRequest
, and Async
classes. Use an arbitrary HTTP verb supported on this class (get, post, put, patch, delete, head; also retry)
x <- HttpClient$new(url = "https://httpbin.org")
x$verb('get')
url fetch
crul
gains new url_fetch
method on HttpClient
and Paginator
classes - get the URL that would be sent in an HTTP request without sending the HTTP request. Useful for getting the URL before executing an HTTP request if you need to check something about the URL first.
shoutout to @boshek for this feature
x <- HttpClient$new(url = "https://httpbin.org")
x$url_fetch()
#> [1] "https://httpbin.org/"
x$url_fetch('get')
#> [1] "https://httpbin.org/get"
x$url_fetch('get', query = list(foo = "bar"))
#> [1] "https://httpbin.org/get?foo=bar"
new vignette
I’ve written a new vignette for the package that covers best practices for working with crul
, vcr
, webmockr
(and coming soon fauxpas
). See the http testing book for more thorough coverage of all these packages.
link to HTTP verbs in crul docs
there are new manual pages for each HTTP verb that’s supported in crul
. before you would say e.g.,
#’ @param … curl options passed on to [crul::HttpClient]
Now, you can say
#’ @param … curl options passed on to [crul::verb-GET]
and that goes to a manual page that covers GET specific details and includes info on the GET HTTP verb itself.
intermediate headers
In the case of multiple intemediate HTTP requests, e.g., redirects, crul
did not collect and give back those intermediate response headers. It only gave back the final set of response headers. There is a new slot response_headers_all
in the HttpResponse
object (what’s returned from HttpClient
, AsyncVaried
, Async
, etc.) that includes an unnamed list of response headers. Now if you need to get those pesky intemediate headers you can do so. For example, on redirects, you may want to get the url given in the location
header.
x <- HttpClient$new("https://doi.org/10.1007/978-3-642-40455-9_52-1")
bb <- x$get()
bb$response_headers_all[[2]]$location
#> [1] "https://link.springer.com/10.1007/978-3-642-40455-9_52-1"