Response | R Documentation |
custom webmockr http response class
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?
new()
Create a new Response
object
Response$new(options = list())
options
(list) a list of options
A new Response
object
print()
print method for the Response
class
Response$print(x, ...)
x
self
...
ignored
set_url()
set the url for the response
Response$set_url(url)
url
(character) a url
nothing returned; sets url
get_url()
get the url for the response
Response$get_url()
(character) a url
set_request_headers()
set the request headers for the response
Response$set_request_headers(headers, capitalize = TRUE)
headers
(list) named list
capitalize
(logical) whether to capitalize first letters of
each header; default: TRUE
nothing returned; sets request headers on the response
get_request_headers()
get the request headers for the response
Response$get_request_headers()
(list) request headers, a named list
set_response_headers()
set the response headers for the response
Response$set_response_headers(headers, capitalize = TRUE)
headers
(list) named list
capitalize
(logical) whether to capitalize first letters of
each header; default: TRUE
nothing returned; sets response headers on the response
get_respone_headers()
get the response headers for the response
Response$get_respone_headers()
(list) response headers, a named list
set_body()
set the body of the response
Response$set_body(body, disk = FALSE)
body
(various types)
disk
(logical) whether its on disk; default: FALSE
nothing returned; sets body on the response
get_body()
get the body of the response
Response$get_body()
various
set_status()
set the http status of the response
Response$set_status(status)
status
(integer) the http status
nothing returned; sets the http status of the response
get_status()
get the http status of the response
Response$get_status()
(integer) the http status
set_exception()
set an exception
Response$set_exception(exception)
exception
(character) an exception string
nothing returned; sets an exception
get_exception()
get the exception, if set
Response$get_exception()
(character) an exception
clone()
The objects of this class are cloneable with this method.
Response$clone(deep = FALSE)
deep
Whether to make a deep clone.
## Not run:
(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()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.