Wikipedia provides a useful list of common http headers: http://en.wikipedia.org/wiki/List_of_HTTP_header_fields.
add_headers(..., .headers = character())
| ... | named header values. To stop an existing header from being
set, pass an empty string: |
|---|---|
| .headers | a named character vector |
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
add_headers(a = 1, b = 2)#> <request> #> Headers: #> * a: 1 #> * b: 2#> <request> #> Headers: #> * a: 1 #> * b: 2GET("http://httpbin.org/headers")#> Response [http://httpbin.org/headers] #> Date: 2020-03-11 04:09 #> Status: 200 #> Content-Type: application/json #> Size: 284 B #> { #> "headers": { #> "Accept": "application/json, text/xml, application/xml, */*", #> "Accept-Encoding": "deflate, gzip", #> "Host": "httpbin.org", #> "User-Agent": "libcurl/7.58.0 r-curl/4.3 httr/1.4.1", #> "X-Amzn-Trace-Id": "Root=1-5e686493-3317c864f866089371cdeea4" #> } #> }# Add arbitrary headers GET( "http://httpbin.org/headers", add_headers(version = version$version.string) )#> Response [http://httpbin.org/headers] #> Date: 2020-03-11 04:09 #> Status: 200 #> Content-Type: application/json #> Size: 332 B #> { #> "headers": { #> "Accept": "application/json, text/xml, application/xml, */*", #> "Accept-Encoding": "deflate, gzip", #> "Host": "httpbin.org", #> "User-Agent": "libcurl/7.58.0 r-curl/4.3 httr/1.4.1", #> "Version": "R version 3.6.2 (2019-12-12)", #> "X-Amzn-Trace-Id": "Root=1-5e686493-302d138cafefc7181fcc2814" #> } #> }# Override default headers with empty strings GET("http://httpbin.org/headers", add_headers(Accept = ""))#> Response [http://httpbin.org/headers] #> Date: 2020-03-11 04:09 #> Status: 200 #> Content-Type: application/json #> Size: 217 B #> { #> "headers": { #> "Accept-Encoding": "deflate, gzip", #> "Host": "httpbin.org", #> "User-Agent": "libcurl/7.58.0 r-curl/4.3 httr/1.4.1", #> "X-Amzn-Trace-Id": "Root=1-5e686493-95411b0fcc1787595d55510c" #> } #> }