14,958
edits
| Line 399: | Line 399: | ||
When executing the curl command, the typical output includes detailed information about the download and upload process as shown below: | When executing the curl command, the typical output includes detailed information about the download and upload process as shown below: | ||
<pre> | <pre> | ||
% curl -o sample.pdf https://example.com/sample.pdf | |||
% Total % Received % Xferd Average Speed Time Time Time Current | % Total % Received % Xferd Average Speed Time Time Time Current | ||
Dload Upload Total Spent Left Speed | Dload Upload Total Spent Left Speed | ||
| Line 414: | Line 416: | ||
</pre> | </pre> | ||
Suggestion: | |||
<pre> | |||
curl -sSf [URL] | |||
</pre> | |||
Adding {{kbd | key=<nowiki>-f</nowiki>}} causes curl to fail on HTTP errors (4xx, 5xx), making it the most robust option for scripts. | |||
<table class="wikitable sortable"> | |||
<tr> | |||
<th>Flag</th> | |||
<th>Error type caught</th> | |||
</tr> | |||
<tr> | |||
<td><span class="flag">-S</span></td> | |||
<td>Network-level errors (DNS failure, connection refused)</td> | |||
</tr> | |||
<tr> | |||
<td><span class="flag">-f</span></td> | |||
<td>HTTP-level errors (4xx, 5xx)</td> | |||
</tr> | |||
<tr> | |||
<td><span class="flag">-sS</span></td> | |||
<td>Silent + network errors</td> | |||
</tr> | |||
<tr> | |||
<td><span class="flag">-sSf</span></td> | |||
<td>Silent + network errors + HTTP errors</td> | |||
</tr> | |||
</table> | |||
=== How to resolve cURL Illegal Filename Character Error === | === How to resolve cURL Illegal Filename Character Error === | ||