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.0.2 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: Mon, 15 Jul 2024 20:51:25 GMT
#> <- access-control-allow-origin: *
#> <- etag: W/"66958bcd-4e7b"
#> <- expires: Tue, 16 Jul 2024 12:34:23 GMT
#> <- cache-control: max-age=600
#> <- content-encoding: gzip
#> <- x-hosts-log-append: pages_hosts_ips:{ [1] = 10.0.18.190,[2] = 10.0.3.132,[3] = 10.0.34.102,}
#> <- x-proxy-cache: MISS
#> <- x-github-request-id: D827:1CCA5F:2F5F882:382E8C8:66966674
#> <- accept-ranges: bytes
#> <- date: Tue, 16 Jul 2024 12:24:45 GMT
#> <- via: 1.1 varnish
#> <- age: 22
#> <- x-served-by: cache-chi-kigq8000047-CHI
#> <- x-cache: HIT
#> <- x-cache-hits: 5
#> <- x-timer: S1721132685.426315,VS0,VE1
#> <- vary: Accept-Encoding
#> <- x-fastly-request-id: 367b55537f94585b0f4b630f7a625112fb4c4a13
#> <- content-length: 5418
#> <- 
#> <httr2_response>
#> GET https://httr2.r-lib.org/
#> Status: 200 OK
#> Content-Type: text/html
#> Body: In memory (20091 bytes)