Skip to content

Latest commit

 

History

History
52 lines (31 loc) · 1006 Bytes

Working with cURL.md

File metadata and controls

52 lines (31 loc) · 1006 Bytes

Using cURL

Downloading files

Download single file

curl <url>
curl http://www.google.com

Output downloaded result to a file

curl <url> > <file>
curl http://www.google.com > google.txt

curl -o <file> <url>
curl -o google.txt http://www.google.com

Output downloaded file based on destination file name (eg. about.html)

curl -O <url>
curl -O https://www.google.com/intl/en/about.html

Fetch and output multiple files

curl -O <url1> <url2> <url3>

Follow location headers

curl -L <url>
curl -L http://google.com

Verbose activity information

curl -v <url>
curl -v http://www.google.com

Resume partially downloaded file

curl -C - -O <url>

Sending requests

Send GET/POST request

curl -X <method> -H "<headers>" -d '<params>' <url>

Example: Send post request for JSON content type to GraphQL endpoint

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"query": "{ field }"}' \
  http://server/graphql