Skip to content

with_verbosity() is useful for debugging httr2 code buried deep inside another package because it allows you to see exactly what's been sent and requested.

Usage

with_verbosity(code, verbosity = 1)

Arguments

code

Code to execture

verbosity

How much information to print? This is a wrapper around req_verbose() that uses an integer to control verbosity:

  • 0: no output

  • 1: show headers

  • 2: show headers and bodies

  • 3: show headers, bodies, and curl status messages.

Use with_verbosity() to control the verbosity of requests that you can't affect directly.

Value

The result of evaluating code.

Examples

fun <- function() {
  request("https://httr2.r-lib.org") |> req_perform()
}
with_verbosity(fun())
#> -> GET / HTTP/2
#> -> Host: httr2.r-lib.org
#> -> User-Agent: httr2/1.1.0.9000 r-curl/6.1.0 libcurl/8.5.0
#> -> Accept: */*
#> -> Accept-Encoding: deflate, gzip, br, zstd
#> -> 
#> <- HTTP/2 200 
#> <- server: GitHub.com
#> <- content-type: text/html; charset=utf-8
#> <- last-modified: Wed, 22 Jan 2025 16:13:02 GMT
#> <- access-control-allow-origin: *
#> <- etag: W/"6791190e-4b1b"
#> <- expires: Fri, 24 Jan 2025 18:55:10 GMT
#> <- cache-control: max-age=600
#> <- content-encoding: gzip
#> <- x-proxy-cache: MISS
#> <- x-github-request-id: 35E0:7C568:1F10884:1FC84DF:6793DFB6
#> <- accept-ranges: bytes
#> <- date: Fri, 24 Jan 2025 18:48:03 GMT
#> <- via: 1.1 varnish
#> <- age: 25
#> <- x-served-by: cache-bur-kbur8200059-BUR
#> <- x-cache: HIT
#> <- x-cache-hits: 5
#> <- x-timer: S1737744483.436245,VS0,VE0
#> <- vary: Accept-Encoding
#> <- x-fastly-request-id: 13c21c9a9b75fd47f672d61fccd85630e24c2e89
#> <- content-length: 4736
#> <- 
#> <httr2_response>
#> GET https://httr2.r-lib.org/
#> Status: 200 OK
#> Content-Type: text/html
#> Body: In memory (19227 bytes)