Debugging HTTP requests is an essential skill for any developer or system administrator. It allows you to inspect the details of your requests and responses, troubleshoot issues, and optimize performance. While there are many tools available for debugging HTTP traffic, Curl is one of the most widely used command line tools. This tutorial explains how to debug requests with a Curl.
Verbose output
The -v
or --verbose
option enables verbose output. It prints detailed information about the request and the response. Lines prefixed with >
represent data sent to the server, lines with <
indicate data received from the server, and lines starting with *
provide miscellaneous information such as connection details, SSL handshake specifics, and protocol information.
curl -v https://httpbin.org/get
curl --verbose https://httpbin.org/get
Output example:
* Trying 34.196.110.25:443...
* Connected to httpbin.org (34.196.110.25) port 443 (#0)
* ALPN, offering h2
...
< HTTP/2 200
< date: Mon, 06 May 2024 14:43:21 GMT
< content-type: application/json
< content-length: 256
< server: gunicorn/19.9.0
< access-control-allow-origin: *
< access-control-allow-credentials: true
<
{
"args": {},
"headers": {
"Accept": "*/*",
"Host": "httpbin.org",
"User-Agent": "curl/7.81.0",
"X-Amzn-Trace-Id": "Root=1-6416c45e-47a4828a557d5fca764271d6"
},
"origin": "XXX.XXX.XXX.XXX",
"url": "https://httpbin.org/get"
}
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Connection #0 to host httpbin.org left intact
Trace output
The --trace
option enables a comprehensive trace dump feature, showcasing all incoming and outgoing data. This trace dump provides a hex dump view of all transmitted and received bytes.
curl --trace - https://httpbin.org/get
Timestamps
The --trace-time
option adds a high-resolution timer to the beginning of verbose/trace outputs whenever a line is printed. This option can be used with -v
/--verbose
option and the --trace
option.
curl -v --trace-time https://httpbin.org/get
curl --trace - --trace-time https://httpbin.org/get
Leave a Comment
Cancel reply