add_headers function

Add additional headers to a request.

Add additional headers to a request.

Wikipedia provides a useful list of common http headers: https://en.wikipedia.org/wiki/List_of_HTTP_header_fields.

add_headers(..., .headers = character())

Arguments

  • ...: named header values. To stop an existing header from being set, pass an empty string: "".
  • .headers: a named character vector

Examples

add_headers(a = 1, b = 2) add_headers(.headers = c(a = "1", b = "2")) ## Not run: GET("http://httpbin.org/headers") # Add arbitrary headers GET( "http://httpbin.org/headers", add_headers(version = version$version.string) ) # Override default headers with empty strings GET("http://httpbin.org/headers", add_headers(Accept = "")) ## End(Not run)

See Also

accept() and content_type() for convenience functions for setting accept and content-type headers.

Other config: authenticate(), config(), set_cookies(), timeout(), use_proxy(), user_agent(), verbose()

  • Maintainer: Hadley Wickham
  • License: MIT + file LICENSE
  • Last published: 2023-08-15