add_headers

0th

Percentile

Add additional headers to a request.

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 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
Details

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

See Also

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

Aliases
  • accept_json
  • accept_xml
  • add_headers
Examples
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))
Documentation reproduced from package httr, version 0.3, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.