| resp_headers {httr2} | R Documentation |
resp_headers() retrieves a list of all headers.
resp_header() retrieves a single header.
resp_header_exists() checks if a header is present.
resp_headers(resp, filter = NULL)
resp_header(resp, header)
resp_header_exists(resp, header)
resp |
An HTTP response object, as created by |
filter |
A regular expression used to filter the header names.
|
header |
Header name (case insensitive) |
resp_headers() returns a list.
resp_header() returns a string if the header exists and NULL otherwise.
resp_header_exists() returns TRUE or FALSE.
resp <- request("https://httr2.r-lib.org") %>% req_perform()
resp %>% resp_headers()
resp %>% resp_headers("x-")
resp %>% resp_header_exists("server")
resp %>% resp_header("server")
# Headers are case insensitive
resp %>% resp_header("SERVER")
# Returns NULL if header doesn't exist
resp %>% resp_header("this-header-doesnt-exist")