Skip to content

Inspect traffic

Copy as code

Copy any captured request from Cloak Proxy as cURL, Python, JavaScript, Swift, Go and 14 more languages, or as a Markdown summary, ready to run or share.

Copy as code turns a captured request into a command or code snippet that sends the same request: same method, URL, headers and body. Use it to reproduce a bug from the terminal, hand a failing call to a teammate, or start a script from what your app really sent. There are 20 formats: cURL, 18 other languages and libraries, and a Markdown summary.

There are four ways, depending on where you are.

  1. Right-click a request in the traffic list.
  2. Choose Copy as cURL, or choose Copy as › and pick a format.

With several requests selected, you get one snippet per request, separated by a blank line.

The Code tab shows the snippet before you copy it.

  1. Choose a format
  2. Copy to the clipboard
The Code tab with cURL selected, showing a curl command with the URL and Authorization, Accept and Cookie headers, and a Copy button

Encrypted tunnels have no request to copy and are skipped.

Menu name Produces
cURL A curl command, one option per line
Swift URLRequest and URLSession.shared.data(for:) with async/await
JavaScript fetch with await. JSON bodies are passed through JSON.stringify.
Python The requests library. JSON bodies become a Python dictionary passed as json=.
Go net/http with http.NewRequest
HTTPie An http command. A body is piped in with echo.
Shell – wget A wget command that prints the response
HTTP The raw HTTP/1.1 request, with Host and Content-Length
NodeJS – Axios axios.request
Python – http.client The standard library’s http.client
Java – OkHttp OkHttp’s Request.Builder
Kotlin – OkHttp OkHttp with Kotlin extensions (toMediaType, toRequestBody)
C# – HttpClient HttpClient and HttpRequestMessage
PHP – cURL curl_setopt_array
Ruby – Net::HTTP Net::HTTP, with use_ssl for HTTPS
Rust – reqwest reqwest::Client in a tokio main function
Dart – http The http package’s http.Request
PowerShell Invoke-RestMethod with a headers dictionary
C – libcurl A small C program using curl_easy
Markdown A heading with the method and URL, a table of headers and the body in a code block. For bug reports and docs, not for running.

The language snippets print the response when they run; most print the status code and the body.

A POST to https://api.example.com/v1/orders with a JSON body and a bearer token comes out like this:

Terminal
curl \
-X POST \
'https://api.example.com/v1/orders' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk_test_xxxx' \
--data-binary '{"sku":"A1","qty":2}'
cURL Markdown Every other format
Method and URL Yes. -X is added unless it’s a GET without a body. Yes, in the heading Yes
Headers All except Content-Length, Connection and Proxy-Connection. Host only when it differs from the URL’s host. All, in a table All except Host, Content-Length, Connection, Proxy-Connection and Accept-Encoding
Text body As --data-binary '…' In a code block, indented if it’s JSON In the language’s own form
Binary body As --data-binary @request-body.bin, for you to supply the file Left out Left out
Compressed request body The captured bytes, so usually @request-body.bin, and --compressed is added Decompressed Decompressed. The Content-Encoding header is still included, so remove it before running.

A copied snippet talks to the server directly, so its traffic doesn’t appear in Cloak Proxy unless the program uses the proxy. To see it, run it from a terminal that’s set up for Cloak Proxy (see Terminal and runtimes), or resend the request from inside the app with Repeat or Edit and Repeat.

To keep a request and work on it, save it to the API client, which has its own code snippets.