curl for checking a web request
Inspect a response, keep its headers and body, and collect enough detail to explain a failed or slow request.
Start with a request you can repeat
Pick one public page or a read-only endpoint in your own lab. These examples use example.com and a POSIX shell, such as Linux or WSL. Run curl --version first and record the version and TLS backend. Another machine may use a different build.
Make a plain GET request with a ten-second time limit. The command writes the response body to your terminal. Record the exact URL, time and any error message. Keep this first result as your baseline before adding options.
curl --version
curl --silent --show-error --max-time 10 https://example.com/Save headers and body separately
Run this from a new working folder so the two output names belong to the current experiment. The header file lets you inspect the status line and fields such as Content-Type and Location. The body file preserves what the server returned.
Read both files before drawing a conclusion. A status of 200 can still accompany an unexpected page, such as a login screen. A redirect gives you a destination to inspect. If you choose to follow it, add --location and compare the resulting response with the original.
curl --silent --show-error --max-time 10 \
--dump-header headers.txt --output body.html \
https://example.com/Separate transfer errors from HTTP responses
A completed transfer can contain an HTTP error response. Use --fail-with-body when you want HTTP status codes of 400 or higher to produce a failure exit status while keeping the response body. This option requires curl 7.76.0 or newer.
In the same shell, print the exit status immediately after curl. Keep that number alongside the HTTP status and error text. If name resolution or TLS fails before an HTTP response arrives, the missing response is itself useful evidence.
curl --silent --show-error --fail-with-body --max-time 10 \
--output response.txt --write-out 'HTTP %{http_code}\n' \
https://example.com/
printf 'curl exit %s\n' "$?"Measure a small set of timings
Collect connection, first-byte and total times with the same request. These values are elapsed seconds measured from the start, so compare them as timestamps within a transfer. Repeat a few times and keep each result. A single slow observation gives you a lead to investigate.
Leave certificate verification enabled. For a private lab certificate authority, supply the approved CA file with --cacert. If verification fails, record the hostname, trust configuration and error before changing anything. Your final note should identify the exact request, observed response and next check.
curl --silent --show-error --max-time 10 --output /dev/null \
--write-out 'connect=%{time_connect} first_byte=%{time_starttransfer} total=%{time_total}\n' \
https://example.com/