Learn R Programming

webmockr (version 0.1.0)

Response: Response class

Description

Response class

Arguments

options
(list) a list of options

Details

Methods
set_request_headers(headers)
set request headers - headers: a list of key-value pair headers
get_request_headers()
get request headers
set_response_headers(headers)
set response headers - headers: a list of key-value pair headers
get_response_headers()
get response headers
set_body(body)
- body: must be a string
get_body()
get body
set_status()
- body: must be an integer status code
get_status()
get status code
set_exception()
set exception
get_exception()
get exception

Examples

Run this code
## 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()
# 
# x$set_exception("exception")
# x
# x$get_exception()
## ---------------------------------------------

Run the code above in your browser using DataLab