Skip to content
  • req_url() replaces the entire url

  • req_url_query() modifies the components of the query

  • req_url_path() modifies the path

  • req_url_path_append() adds to the path

Usage

req_url(req, url)

req_url_query(.req, ...)

req_url_path(req, ...)

req_url_path_append(req, ...)

Arguments

req, .req

A request.

url

New URL; completely replaces existing.

...

For req_url_query(): Name-value pairs that provide query parameters. Each value must be either a length-1 atomic vector (which is automatically escaped) or NULL (which is silently dropped). If you want to opt out of escaping, wrap strings in I().

For req_url_path() and req_url_path_append(): A sequence of path components that will be combined with /.

Value

A modified HTTP request.

Examples

req <- request("http://example.com")

# Change url components
req %>%
  req_url_path_append("a") %>%
  req_url_path_append("b") %>%
  req_url_path_append("search.html") %>%
  req_url_query(q = "the cool ice")
#> <httr2_request>
#> GET http://example.com/a/b/search.html?q=the%20cool%20ice
#> Body: empty

# Change complete url
req %>%
  req_url("http://google.com")
#> <httr2_request>
#> GET http://google.com
#> Body: empty