Skip to content

Parses URLs out of the the Link header as defined by RFC 8288.

Usage

resp_link_url(resp, rel)

Arguments

resp

A httr2 response object, created by req_perform().

rel

The "link relation type" value for which to retrieve a URL.

Value

Either a string providing a URL, if the specified rel exists, or NULL if not.

Examples

# Simulate response from GitHub code search
resp <- response(headers = paste0("Link: ",
  '<https://api.github.com/search/code?q=addClass+user%3Amozilla&page=2>; rel="next",',
  '<https://api.github.com/search/code?q=addClass+user%3Amozilla&page=34>; rel="last"'
))

resp_link_url(resp, "next")
#> [1] "https://api.github.com/search/code?q=addClass+user%3Amozilla&page=2"
resp_link_url(resp, "last")
#> [1] "https://api.github.com/search/code?q=addClass+user%3Amozilla&page=34"
resp_link_url(resp, "prev")
#> NULL