raise_for_ct(type, charset = NULL, behavior = "stop"): Check response content-type; stop or warn if not matched. Parameters:
* type: (character) a mime type to match against; see mime::mimemap for allowed values
* charset: (character) if a charset string given, we check that it matches the charset in the content type header. default: NULL
* behavior: (character) one of stop (default) or warning
raise_for_ct_html(charset = NULL, behavior = "stop"): Check that the response content-type is text/html; stop or warn if not matched. Parameters: see raise_for_ct()
raise_for_ct_json(charset = NULL, behavior = "stop"): Check that the response content-type is application/json; stop or warn if not matched. Parameters: see raise_for_ct()
raise_for_ct_xml(charset = NULL, behavior = "stop"): Check that the response content-type is application/xml; stop or warn if not matched. Parameters: see raise_for_ct()
R6 classes
This is an R6 class from the package R6. Find out more about R6 at https://r6.r-lib.org/. After creating an instance of an R6 class (e.g., x <- HttpClient$new(url = "https://hb.opencpu.org")) you can access values and methods on the object x.
request_headers: (list) request headers, named list
response_headers: (list) response headers, named list
response_headers_all: (list) all response headers, including intermediate redirect headers, unnamed list of named lists
modified: (character) modified date
times: (vector) named vector
content: (raw) raw binary content response
request: request object, with all details
Method parse()
Parse the raw response content to text
Usage
HttpResponse$parse(encoding = NULL, ...)
Arguments
encoding: (character) A character string describing the current encoding. If left as NULL, we attempt to guess the encoding. Passed to from parameter in iconv
...: additional parameters passed on to iconv (options: sub, mark, toRaw). See ?iconv for help
Returns
character string
Method success()
Was status code less than or equal to 201
Usage
HttpResponse$success()
Returns
boolean
Method status_http()
Get HTTP status code, message, and explanation
Usage
HttpResponse$status_http(verbose = FALSE)
Arguments
verbose: (logical) whether to get verbose http status description, default: FALSE
Returns
object of class "http_code", a list with slots for status_code, message, and explanation
Method raise_for_status()
Check HTTP status and stop with appropriate HTTP error code and message if >= 300. otherwise use httpcode. If you have fauxpas installed we use that.
Usage
HttpResponse$raise_for_status()
Returns
stop or warn with message
Method clone()
The objects of this class are cloneable with this method.