This expectation checks that a HTTP header (and potentially header value) is present in a request. It works by inspecting the request object and raising warnings that are caught by testthat::expect_warning().

expect_header(...)

Arguments

...

Arguments passed to expect_warning

Value

NULL, according to expect_warning.

Details

expect_header works both in the mock HTTP contexts and on "live" HTTP requests.

Examples

library(httr) with_fake_http({ expect_header(GET("http://example.com", config=add_headers(Accept="image/png")), "Accept: image/png") })
#> GET http://example.com
#> Response [http://example.com] #> Date: 2018-06-19 21:15 #> Status: 200 #> Content-Type: <unknown> #> Size: 4 B #> <BINARY BODY>