req_verbose()
uses the following prefixes to distinguish between
different components of the HTTP requests and responses:
*
informative curl messages->
request headers>>
request body<-
response headers<<
response body
Usage
req_verbose(
req,
header_req = TRUE,
header_resp = TRUE,
body_req = FALSE,
body_resp = FALSE,
info = FALSE,
redact_headers = TRUE
)
Arguments
- req
A request.
- header_req, header_resp
Show request/response headers?
- body_req, body_resp
Should request/response bodies? When the response body is compressed, this will show the number of bytes received in each "chunk".
- info
Show informational text from curl? This is mainly useful for debugging https and auth problems, so is disabled by default.
- redact_headers
Redact confidential data in the headers? Currently redacts the contents of the Authorization header to prevent you from accidentally leaking credentials when debugging/reprexing.
Value
A modified HTTP request.
See also
req_perform()
which exposes a limited subset of these options
through the verbosity
argument and with_verbosity()
which allows you
to control the verbosity of requests deeper within the call stack.
Examples
# Use `req_verbose()` to see the headers that are sent back and forth when
# making a request
resp <- request("https://httr2.r-lib.org") |>
req_verbose() |>
req_perform()
#> -> 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:40 GMT
#> <- via: 1.1 varnish
#> <- age: 17
#> <- x-served-by: cache-chi-kigq8000047-CHI
#> <- x-cache: HIT
#> <- x-cache-hits: 1
#> <- x-timer: S1721132681.615866,VS0,VE1
#> <- vary: Accept-Encoding
#> <- x-fastly-request-id: 2e608fc826390822ab906e799ea816240146553f
#> <- content-length: 5418
#> <-
# Or use one of the convenient shortcuts:
resp <- request("https://httr2.r-lib.org") |>
req_perform(verbosity = 1)
#> -> 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:40 GMT
#> <- via: 1.1 varnish
#> <- age: 17
#> <- x-served-by: cache-chi-kigq8000047-CHI
#> <- x-cache: HIT
#> <- x-cache-hits: 2
#> <- x-timer: S1721132681.627810,VS0,VE0
#> <- vary: Accept-Encoding
#> <- x-fastly-request-id: c1f095a895acad9f29aeb158387530e1f5216676
#> <- content-length: 5418
#> <-