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 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.
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.1.9000 r-curl/5.2.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: Tue, 02 Apr 2024 13:46:47 GMT
#> <- access-control-allow-origin: *
#> <- etag: W/"660c0c47-4e7b"
#> <- expires: Fri, 17 May 2024 09:59:25 GMT
#> <- cache-control: max-age=600
#> <- content-encoding: gzip
#> <- x-proxy-cache: MISS
#> <- x-github-request-id: 323C:15240C:48C535:5487D1:66472824
#> <- accept-ranges: bytes
#> <- date: Fri, 17 May 2024 10:50:34 GMT
#> <- via: 1.1 varnish
#> <- age: 24
#> <- x-served-by: cache-iad-kiad7000063-IAD
#> <- x-cache: HIT
#> <- x-cache-hits: 5
#> <- x-timer: S1715943035.648439,VS0,VE0
#> <- vary: Accept-Encoding
#> <- x-fastly-request-id: 53eea2bc66ed39bfef8a1fcbdef71afaffa97e8e
#> <- content-length: 5418
#> <-
#> <httr2_response>
#> GET https://httr2.r-lib.org/
#> Status: 200 OK
#> Content-Type: text/html
#> Body: In memory (20091 bytes)