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.0.6.9000 r-curl/6.0.1 libcurl/7.81.0
#> -> accept: */*
#> -> accept-encoding: deflate, gzip, br, zstd
#> ->
#> <- HTTP/2 200
#> <- server: GitHub.com
#> <- content-type: text/html; charset=utf-8
#> <- last-modified: Thu, 14 Nov 2024 18:24:41 GMT
#> <- access-control-allow-origin: *
#> <- etag: W/"67364069-4983"
#> <- expires: Tue, 19 Nov 2024 06:21:19 GMT
#> <- cache-control: max-age=600
#> <- content-encoding: gzip
#> <- x-proxy-cache: MISS
#> <- x-github-request-id: 5F16:3C70E3:1BE6358:1E1A9E6:673C2C06
#> <- accept-ranges: bytes
#> <- date: Tue, 19 Nov 2024 07:53:51 GMT
#> <- via: 1.1 varnish
#> <- age: 338
#> <- x-served-by: cache-chi-kigq8000032-CHI
#> <- x-cache: HIT
#> <- x-cache-hits: 5
#> <- x-timer: S1732002831.475224,VS0,VE0
#> <- vary: Accept-Encoding
#> <- x-fastly-request-id: 4c8e8516780a152c2806a9db3f7a49db5742eac9
#> <- content-length: 4636
#> <-
#> <httr2_response>
#> GET https://httr2.r-lib.org/
#> Status: 200 OK
#> Content-Type: text/html
#> Body: In memory (18819 bytes)