Curl Body



These curl recipes show you how to debug curl requests to see what it's sending and receiving. By default, curl only prints the response body. To make it print the full communication, including the request headers, SSL certificate information, response headers, and response body, use the -v command line argument. To make it print a hexdump of everything, use the --trace argument. To make it print both the response headers and the body, use the -i command line argument.

  1. Curl Body Shop
  2. Curl Body Shop
Curl Body

Make Curl Verbose

Curl Body

I am using cURL command line utility to send HTTP POST to a web service. I want to include a file's contents as the body entity of the POST. I have tried using -d. CURL is a tool for data transfer. It is also available as a library for developers and as a CLI for terminal-based use cases. Both have the same engine inside (Truth is that CLI tool is just the program that uses the library under the hood).

This recipe uses the -v argument to make curl print detailed information about the request and the response. Lines prefixed by > is the data sent to the server, lines prefixed by < is the data received from the server, and lines starting with * is misc information, such as connection information, SSL handshake information, and protocol information.

Detailed Trace

In this recipe, we use the --trace - argument to enable full trace dump of all incoming and outgoing data. The trace dump prints hexdump of all bytes sent and received.

Curl BodyCurl

Detailed Trace with Timestamps

This recipe adds --trace-time argument to curl. This argument, combined with --trace - makes curl print a detailed trace log. You can also combine --trace-time with -v to add timestamps to curl's verbose output.

Curl Body

Include Response Headers in the Output

By default, curl prints the response body to the screen. This recipe uses the -i Fallout new vegas download for mac. argument to make it also print response headers. When this flag is specified, curl will first print the response headers, then a blank line, then the response body.

Print Only the Response Headers

To print only the response headers (and discard the body), three arguments have to be used together. The -s argument makes curl silent and hides errors and progress bar, then -o /dev/null (if you're on Windows, use -o NUL) makes curl ignore the response body, and -D - prints response headers to stdout (- is stdout).

Print Only the Request Headers

Curl Body Shop

There is no easy way to print just the request headers with curl. You have to shell out to an external helper program to do it and use a bunch of command line options to disable all other output. This recipe enables the verbose output via the -v argument, then makes curl silent via the -s argument, then makes curl ignore the output from the server via the -o /dev/null argument, then makes curl to redirect stderr to stdout via the --stderr - argument, and finally asks grep to print all lines that begin with > that contain request headers.

Print Only the Response Code

Curl Body Shop

This recipe uses the -w argument that makes curl print extra information after the request has completed. The extra information we're asking it to print is %{response_code} which is the response code of the request. To make curl only print the code and not the content or other information, we also use -s to silence curl and -o /dev/null that ignores the response output.

Created by Browserling

These curl recipes were written down by me and my team at Browserling. We use recipes like this every day to get things done and improve our product. Browserling itself is an online cross-browser testing service powered by alien technology. Check it out!

Secret message: If you love my curl recipe, then I love you, too! Short keyboard for mac. Use coupon code CURLLING to get a discount at my company.