content_type: Set content-type and accept headers.

Description Usage Arguments Details Examples

View source: R/headers.r

Description

These are convenient wrappers aroud add_headers.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11

Arguments

type

A mime type or a file extension. If a file extension (i.e. starts with .) will guess the mime type using guess_type.

Details

accept_json/accept_xml and content_type_json/content_type_xml are useful shortcuts to ask for json or xml responses or tell the server you are sending json/xml.

Examples

1
2
3
4
5
6
7
8
9
GET("http://httpbin.org/headers")

GET("http://httpbin.org/headers", accept_json())
GET("http://httpbin.org/headers", accept("text/csv"))
GET("http://httpbin.org/headers", accept(".doc"))

GET("http://httpbin.org/headers", content_type_xml())
GET("http://httpbin.org/headers", content_type("text/csv"))
GET("http://httpbin.org/headers", content_type(".xml"))

httr documentation built on May 19, 2017, 8:53 a.m.

Search within the httr package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.