Tips and trick using curl

Categories: linux webserver

Download files

curl -O
curl -O -L # Follows links. In this example the http request will be redirected to https
curl -o test.json # Saves the file as test.json

Send host header

Usefull when the server is hosting multiple domains

curl -H "host:"


Show host headers

curl -I

HTTP/2 200 
server: openresty
date: Fri, 18 Aug 2023 11:03:58 GMT
content-type: text/html
content-length: 1543
last-modified: Fri, 18 Aug 2023 10:54:36 GMT
etag: "64df4dec-607"
accept-ranges: bytes

Force dns resolution

This can be really usefull when testing configuration before making any changes to DNS.

curl --resolve