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/0.2.2.9000 r-curl/4.3.2 libcurl/7.68.0
#> -> accept: */*
#> -> accept-encoding: deflate, gzip, br
#> -> 
#> <- HTTP/2 200 
#> <- server: GitHub.com
#> <- content-type: text/html; charset=utf-8
#> <- last-modified: Sun, 25 Sep 2022 19:23:12 GMT
#> <- access-control-allow-origin: *
#> <- etag: W/"6330aaa0-4c8b"
#> <- expires: Sun, 25 Sep 2022 19:35:09 GMT
#> <- cache-control: max-age=600
#> <- content-encoding: gzip
#> <- x-proxy-cache: MISS
#> <- x-github-request-id: 1AFC:5B0B:16D41A2:208470C:6330AB15
#> <- accept-ranges: bytes
#> <- date: Sun, 25 Sep 2022 19:25:28 GMT
#> <- via: 1.1 varnish
#> <- age: 19
#> <- x-served-by: cache-iad-kiad7000046-IAD
#> <- x-cache: HIT
#> <- x-cache-hits: 5
#> <- x-timer: S1664133929.597797,VS0,VE1
#> <- vary: Accept-Encoding
#> <- x-fastly-request-id: b386170c73a5aa589d4337030f86abb7ad26695e
#> <- content-length: 5254
#> <- 
#> <httr2_response>
#> GET https://httr2.r-lib.org/
#> Status: 200 OK
#> Content-Type: text/html
#> Body: In memory (19595 bytes)