Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

parse_headers

Parse response headers


Description

Parse response header data as returned by curl_fetch, either as a set of strings or into a named list.

Usage

parse_headers(txt, multiple = FALSE)

parse_headers_list(txt)

Arguments

txt

raw or character vector with the header data

multiple

parse multiple sets of headers separated by a blank line. See details.

Details

The parse_headers_list function parses the headers into a normalized (lowercase field names, trimmed whitespace) named list.

If a request has followed redirects, the data can contain multiple sets of headers. When multiple = TRUE, the function returns a list with the response headers for each request. By default it only returns the headers of the final request.

Examples

req <- curl_fetch_memory("https://httpbin.org/redirect/3")
parse_headers(req$headers)
parse_headers(req$headers, multiple = TRUE)

# Parse into named list
parse_headers_list(req$headers)

curl

A Modern and Flexible Web Client for R

v4.3.1
MIT + file LICENSE
Authors
Jeroen Ooms [aut, cre] (<https://orcid.org/0000-0002-4035-0289>), Hadley Wickham [ctb], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.