httr (version 0.1.1)

add_headers: Add additional headers to a request.

Description

accept_json and accept_xml are useful shortcuts to request json or xml responses if the server supports content negotiation. json and xml are both easy to work with in R. See parsed_content for how to access the results as R objects.

Usage

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

accept_json()

accept_xml()

Arguments

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

See Also

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

Examples

Run this code
add_headers(a = 1, b = 2)
add_headers(.headers = c(a = "1", b = "2"))

# Override default headers with empty strings
GET("http://had.co.nz", verbose())
GET("http://had.co.nz", c(verbose(), add_headers(Accept = "")))

GET("http://httpbin.org/headers")
GET("http://httpbin.org/headers",
 add_headers(version = version$version.string))

Run the code above in your browser using DataLab