Skip to contents

Convenience wrapper around a bunch of httr2 functions.

Usage

req_cached(url, max_tries = 3L)

Arguments

url

HTTP protocol address. The scheme is optional, so both "google.com" and "https://google.com" will work. A character scalar.

max_tries

Maximum number of attempts to retry in case of an HTTP error. An integerish scalar.

Value

  • If the HTTP request succeeds, and the status code is ok (e.g. 200), an HTTP response.

  • If the HTTP request succeeds, but the status code is an error (e.g a 404), an error with class c("httr2_http_404", "httr2_http"). By default, all 400 and 500 status codes will be treated as an error, but you can customise this with req_error().

  • If the HTTP request fails (e.g. the connection is dropped or the server doesn't exist), an error with class "httr2_failure".

See also

Other HTTP functions: assert_mime_type(), is_http_success(), is_url()