forked from r-lib/httr2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttr2_translate.Rd
More file actions
41 lines (38 loc) · 1.21 KB
/
Copy pathhttr2_translate.Rd
File metadata and controls
41 lines (38 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/httr2-translate.R
\name{httr2_translate}
\alias{httr2_translate}
\title{Translate a httr2 request to a curl command}
\usage{
httr2_translate(req, obfuscated = c("redact", "reveal"))
}
\arguments{
\item{req}{A httr2 \link{request} object.}
\item{obfuscated}{Form and JSON bodies can contain \link{obfuscated} values.
This argument control what happens to them: should they be removed,
redacted, or revealed.}
}
\value{
A string containing the curl command.
}
\description{
Convert a httr2 request object to an approximate curl command line call.
This is useful for debugging, for sharing a request with someone who doesn't
use R, or for handing off to another tool.
}
\examples{
# Basic GET request
request("https://httpbin.org/get") |>
httr2_translate()
# POST with JSON body
request("https://httpbin.org/post") |>
req_body_json(list(name = "value")) |>
httr2_translate()
# Secrets are redacted by default, but can be revealed
request("https://example.com") |>
req_headers_redacted(Authorization = "secret") |>
httr2_translate(obfuscated = "reveal")
}
\seealso{
\code{\link[=curl_translate]{curl_translate()}} to translate in the other direction.
}