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.
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 output1
: show headers2
: show headers and bodies3
: show headers, bodies, and curl status messages.
Use
with_verbosity()
to control the verbosity of requests that you can't affect directly.
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 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: Tue, 21 Jan 2025 18:09:41 GMT
#> <- access-control-allow-origin: *
#> <- etag: W/"678fe2e5-4983"
#> <- expires: Wed, 22 Jan 2025 16:21:49 GMT
#> <- cache-control: max-age=600
#> <- content-encoding: gzip
#> <- x-proxy-cache: MISS
#> <- x-github-request-id: 500D:3D2BDE:10B3E7:113A45:679118C1
#> <- accept-ranges: bytes
#> <- date: Wed, 22 Jan 2025 16:12:13 GMT
#> <- via: 1.1 varnish
#> <- age: 25
#> <- x-served-by: cache-pao-kpao1770061-PAO
#> <- x-cache: HIT
#> <- x-cache-hits: 5
#> <- x-timer: S1737562333.405277,VS0,VE0
#> <- vary: Accept-Encoding
#> <- x-fastly-request-id: 7cd37c1f70ef2538adba0f4cae18e9262dc3c4c7
#> <- content-length: 4638
#> <-
#> <httr2_response>
#> GET https://httr2.r-lib.org/
#> Status: 200 OK
#> Content-Type: text/html
#> Body: In memory (18819 bytes)