tests/testthat/test-req-method.R

test_that("can override default method", {
  req <- request("http://example.com")

  expect_equal(req$method, NULL)

  req <- req_method(req, "patch")
  expect_equal(req$method, "PATCH")
})

test_that("correctly guesses default method", {
  req <- request("http://example.com")
  expect_equal(req_method_get(req), "GET")

  req <- req_body_raw(req, "abc")
  expect_equal(req_method_get(req), "POST")

  req <- req_options(req, nobody = TRUE)
  expect_equal(req_method_get(req), "HEAD")
})

Try the httr2 package in your browser

Any scripts or data that you put into this service are public.

httr2 documentation built on Nov. 14, 2023, 5:08 p.m.