curl Commands
Transfer data with URLs.All curl pages
- curl -I / curl -i: show the HTTP response headerscurl -I prints the response headers of a HEAD request, curl -i headers plus body, and -D - -o /dev/null the headers of a real GET. Status code only with -w.
- curl -L: follow redirects (301, 302) with curlcurl -L follows 301, 302, 307 and 308 redirects to the final URL. Why POST turns into GET, --max-redirs and error 47, and printing the final URL with -w.
- curl -O / curl -o file: download a file with curlcurl -O saves a download under the URL's file name and -o under a name you pick. Add -L for redirects and -f to fail on 404; resume with -C - and check it.
- curl POST JSON: send a JSON body with curlSend JSON with curl -H 'Content-Type: application/json' -d '{...}' or with --json (curl 7.82+). Without the header, -d posts form data. Tested on a server.