View source: R/expect-request-header.R
expect_request_header | R Documentation |
This expectation checks that HTTP headers (and potentially header values) are present in a request. It works both in the mock HTTP contexts and on "live" HTTP requests.
expect_request_header(
expr,
...,
fixed = FALSE,
ignore.case = FALSE,
perl = FALSE,
useBytes = FALSE
)
expr |
Code to evaluate |
... |
Named headers to match. Values should either be a string (length-1
character), which will be passed to |
fixed |
logical. If |
ignore.case |
if |
perl |
logical. Should Perl-compatible regexps be used? |
useBytes |
logical. If |
The value of expr
if there are no expectation failures
library(httr2)
expect_request_header(
request("http://httpbin.org") %>%
req_headers(Accept = "image/png") %>%
req_perform(),
accept = "image/png",
`x-fake-header` = NULL
)
expect_request_header(
request("http://httpbin.org") %>%
req_headers(Accept = "image/png") %>%
req_perform(),
accept = ""
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.