Skip to content

Latest commit

 

History

History
95 lines (75 loc) · 1.59 KB

curl.md

File metadata and controls

95 lines (75 loc) · 1.59 KB

curl


  • cURL help menu
curl -h
  • Basic GET request
curl www.example.com
  • Download file
curl -s -O example.tcom/index.html
  • Skip HTTPS (SSL) certificate validation
curl -k https://example.com
  • Print full HTTP requesst/reponse details
curl example.com -v
  • Send HEAD request (only prints response header)
curl -I https://example.com
  • Print response headers and body
curl -i https://example.com
  • Set User-Agent header
curl https://example.com -A "Mozilla/5.0"
  • Pass HTTP basic authorization credentials in the URL
curl https://username:password@example.com:1234
  • Set request header
curl -H "Authorization: Basic URNADkd=" https://example.com
  • Pass GET parameters
curl "https://example.com/search.php?search=ls"
  • Send POST request with POST data
curl -X POST -d "username=admin&password=pass" https://example.com
  • Set request cookies
curl -b "PHPSESSID=ckljgdnfakdlssa1" https://example.com
  • Send POST request with JSON data
curl -X POST -d "{'search':'htb'}" -H "Content-Type: application/json" https://example.com/search.php

curl with APIs

  • Read entry
curl https://example.com/api.php/city/newyork
  • Read all entries
curl -s https://example.com/api,php/city | jq
  • Create (add) an entry
curl -X PUT https://example.com/api.php/city -d "{'city':'LA','country':'USA'}" -H "Content-Type: application/json"
  • Delete an entry
curl -X DELETE https://example.com/api.php/city/LA