brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: curl --trace-ascii dumps all sent and received data as readable text

Curl
~/tips/tip-curl-trace-ascii-full-dump

curl --trace-ascii - https://example.com/

Writes a readable log of everything curl sends and receives, headers and body included.

When a request misbehaves, the raw conversation is what you want to see. curl has a trace option that stays readable, with no hex columns to squint at.

curl --trace-ascii - https://example.com/

The manual says --trace-ascii saves a full trace dump of all incoming and outgoing data, including descriptive information, in the file you name. A - as the file name sends it to stdout, and % sends it to stderr. For a plain HTTP request to a small server, a short piece of the output looks like this:

=> Send header, 87 bytes (0x57)
0000: GET /index.html HTTP/1.1
0030: User-Agent: curl/8.5.0
<= Recv header, 17 bytes (0x11)
0000: HTTP/1.0 200 OK
<= Recv data, 3 bytes (0x3)
0000: hi

Lines starting with => are what curl sent and lines with <= are what came back. The body appears too, as Recv data. If you also want to know when each step happened, add --trace-time, which prepends a time stamp to each trace or verbose line.

curl --trace-ascii trace.txt --trace-time https://example.com/

Two caveats. The manual says --trace-ascii is mutually exclusive with --trace and --verbose, so use one of them per command. And the trace holds everything: authorization headers, cookies and bodies. Read it before you paste it into an issue or a chat, and remove the secrets.

Further reading: curl man page

More Curl tips Retry-After: 120 curl -fsS --fail-early \ url = "https://example.com/data/latest.json" curl -4 -s -o /dev/null -w '%{remote_ip} %{http_code}\n' https://example.com/ curl -q -fsS https://example.com/api/status All Curl tips (71) All topics

Link