Examples for 'crul::content-types'


Working with content types

Aliases: content-types

Keywords:

### ** Examples

## Not run: 
##D (x <- HttpClient$new(url = "https://hb.opencpu.org"))
##D (res <- x$get())
##D 
##D ## see the content type
##D res$response_headers
##D 
##D ## check that the content type is text/html
##D res$raise_for_ct_html()
##D 
##D ## it's def. not json
##D # res$raise_for_ct_json()
##D 
##D ## give custom content type
##D res$raise_for_ct("text/html")
##D # res$raise_for_ct("application/json")
##D # res$raise_for_ct("foo/bar")
##D 
##D ## check charset in addition to the media type
##D res$raise_for_ct_html(charset = "utf-8")
##D # res$raise_for_ct_html(charset = "utf-16")
##D 
##D # warn instead of stop
##D res$raise_for_ct_json(behavior = "warning")
## End(Not run)

[Package crul version 1.5.0 Index]