[WIP]cURL Tutorial
created: 2023/1/23
https://www.booleanworld.com/curl-command-tutorial-examples/
cURL basic usage | |
|
|
Downloading Files with cURL |
|
-o, --output <file> |
|
-O, --remote-name |
Bear in mind that when you use the |
-C, --continue-at <offset> |
Use "-C -" to tell curl to automatically find out where/how to resume the transfer.
Like most other command line tools, you can combine different options together. For example, in the above command, you could combine |
Anatomy of a HTTP request/response | |
Following redirects with cURL | |
-L, --location |
|
Viewing response headers with cURL | |
-i, --include |
|
Viewing request headers and connection details |
|
-v, --verbose |
|
Silencing errors | |
-s, --silent |
|
-S, --show-error |
This option is global and does not need to be specified |
Setting HTTP request headers with cURL | |
-H, --header <header/@file> |
See also -A, --user-agent and -e, --referer. |
-A, --user-agent <name> |
cURL does have certain shortcuts for frequently used flags. You can set the “User-Agent” header with the |
-e, --referer <URL> |
The “Referer” header is used to tell the server the location from which they were referred to by the previous site. It is typically sent by browsers when requesting Javascript or images linked to a page, or when following redirects. If you want to set a “Referer” header, you can use the |
Making POST requests with cURL | |
-d, --data <data> |
If the
|
--data-urlencode <data> |
Alternatively, you can just use |
-F, --form <name=content> |
|
Submitting JSON data with cURL | |
-d with
|
|
You can also save the JSON file, and submit it in the same way as we did previously: |
|
Changing the request method | |
WIP | |
Replicating browser requests with cURL | |
Making cURL fail on HTTP errors | |
Making authenticated requests with cURL | |
Testing protocol support with cURL |
|
Setting the Host header and cURL’s --resolve option | |
Resolve domains to IPv4 and IPv6 addresses | |
Disabling cURL’s certificate checks | |
Troubleshooting website issues with “cURL timing breakdown” | |
cURL configuration files | |
Conclusion | |