crul release v0.7.0 - many new features

, ,

A new minor version release (v0.7.0) of crul is on CRAN.

Release notes:

This release includes many new features:


crul gains new retry method on the HttpClient class

big thanks to @hlapp for all the work on this :clap:

x <- HttpClient$new(url = "")

# 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))


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 = "")

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 = "")
#> [1] ""
#> [1] ""
x$url_fetch('get', query = list(foo = "bar"))
#> [1] ""

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("")
bb <- x$get()
#> [1] ""