Use this function to use a custom HTTP method like HEAD
,
DELETE
, PATCH
, UPDATE
, or OPTIONS
. The default method is
GET
for requests without a body, and POST
for requests with a body.
Arguments
- req
A httr2 request object.
- method
Custom HTTP method
Value
A modified HTTP request.
Examples
request(example_url()) |> req_method("PATCH")
#> <httr2_request>
#> PATCH http://127.0.0.1:36837/
#> Body: empty
request(example_url()) |> req_method("PUT")
#> <httr2_request>
#> PUT http://127.0.0.1:36837/
#> Body: empty
request(example_url()) |> req_method("HEAD")
#> <httr2_request>
#> HEAD http://127.0.0.1:36837/
#> Body: empty