custom webmockr http response class
Public fields
url
(character) a url
body
(various) list, character, etc
content
(various) response content/body
request_headers
(list) a named list
response_headers
(list) a named list
options
(character) list
status_code
(integer) an http status code
exception
(character) an exception message
should_timeout
(logical) should the response timeout?
Methods
Method print()
print method for the Response
class
Method set_request_headers()
set the request headers for the response
Method set_response_headers()
set the response headers for the response
Examples
if (FALSE) { # \dontrun{
(x <- Response$new())
x$set_url("https://httpbin.org/get")
x
x$set_request_headers(list("Content-Type" = "application/json"))
x
x$request_headers
x$set_response_headers(list("Host" = "httpbin.org"))
x
x$response_headers
x$set_status(404)
x
x$get_status()
x$set_body("hello world")
x
x$get_body()
# raw body
x$set_body(charToRaw("hello world"))
x
x$get_body()
x$set_exception("exception")
x
x$get_exception()
} # }