Skip to content
subcloakdocs

Inspect traffic

Copy as code

Copy any captured request as cURL, Python, JavaScript, Swift, Go, a k6 load test, a Playwright test and more, 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 24 formats: cURL, 21 other languages, libraries and test tools, a Markdown summary, and a .http file.

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 line-numbered 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.

A request paused at a breakpoint has its own Copy menu, which copies it with your edits. See Copy the paused request.

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
k6 – load test Since 0.2.0 A k6 script that sends the request with 10 virtual users for 30 seconds (options = { vus: 10, duration: '30s' }), checks for a 2xx status and sleeps a second between iterations. Run it with k6 run.
Python – httpx Since 0.2.0 The httpx library. JSON bodies become a Python dictionary passed as json=; other text bodies go in content=.
Playwright – API test Since 0.2.0 A @playwright/test test named after the method and path that sends the request with request.fetch and expects response.ok(). JSON bodies go in data.
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.
.http (REST Client) A .http request for VS Code’s REST Client, JetBrains HTTP Client or Cloak Proxy’s own .http files: a ### title, the request line, the headers (without Host and Content-Length) and the body, decompressed.

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

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. --compressed is added when the request has Accept-Encoding. All, in a table All except Host, Content-Length, Connection, Proxy-Connection and Accept-Encoding
Text body As --data-raw '…', so a body that starts with @ is never read as a file In a code block, indented if it’s JSON In the language’s own form
Binary body Printed by printf and piped in with --data-binary @-, so the command needs no extra file Left out Left out
Compressed request body The captured bytes, piped in like a binary body 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.

To get type definitions for a JSON response or request body instead of code that sends the request, right-click the request and choose Generate Types from Response… or Generate Types from Request Body…. See Generate types.