DEV Community

Arpit Kumar
Arpit Kumar

Posted on • Updated on

Powerful options in cURL

Most of us use cURL for GET requests.

Few less used but powerful options in cURL. A curly thread ๐Ÿงต

  1. Verbose output with -v
    curl -v www.cnn.com
    verbose

  2. Follow redirects with -L
    curl -L www.cnn.com
    redirect

  3. Download a file with a new name with -o
    curl -o myfile.csv https://example.com/file.csv
    download

  4. Resume an interrupted download with -C -
    curl -C - -O https://images.unsplash.com/photo-1641762256336-16cb15d5850a
    resume-download

  5. Store website cookie in file with --cookie-jar
    curl --cookie-jar cnncookies.txt https://www.cnn.com/index.html -O
    cookie jar

  6. Send website cookies with --cookie
    curl --cookie cnncookies.txt https://www.cnn.com/index.html
    send cookie

  7. Retry on failure with --retry
    curl --retry 5 --retry-max-time 120 https://www.cnn.com/index.html
    retry

  8. Use proxy for curl with or without authentication with -x and -U
    curl -x proxy.yourdomain.com:8080 -U user:password -O https://yourdomain.com/yourfile.tar.gz
    proxy

  9. Modify Name Resolution with --resolve
    curl --resolve www.example.com:80:localhost https://www.example.com
    name resolution

  10. Retrieve particular byte range with -r
    curl -r 0-20000 -o myfile.png https://images.unsplash.com/photo-1641762256336-16cb15d5850a
    byte range

Want to know more. There's an actual gitbook you can refer -

Read https://everything.curl.dev

Any other powerful cURL usage which we should know ?

Top comments (0)