curl: transfer a url

curl GET

  • Access a url
  • Access a https url
    # -k (--insecure) to fetch with TSL
    curl -k
  • Additional headers
    curl -H "content-type: application/json" -H ...
  • Basic Authentication
    curl -u user:password
  • with JWT Token
    curl -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" https://my.restful.api/path
  • with referer
    curl -e localhost localhost/some/other/path
  • verbose details headers, -v(–verbose)
    # A line starting with '>' means "header data" sent by curl, '<' means "header data" received
    curl -kv
  • Display response headers
     curl --head -k
  • use proxy for connecting
    curl --proxy yourproxy:port

curl POST

  • POST with single field
    curl -XPOST -d oneKey=simpleValu
  • POST with json data
    curl -XPOST -d '{"id":"1","name":"my name"}'
  • POST with json data in a local file
    curl -X POST -H "Content-Type: application/json" -d @../path/to/data DESTINATION
  • POST with formdata, -F/–form <name=content>, e.g.
    curl \
    -F "filename=new image" \
    -F "filetype=image" \
    -F "file=@/home/user1/Desktop/test.jpg" \

curl with proxy

curl --header "X-Forwarded-For:" http_url

curl on behalf of