tldr/pages/common/curl.md

33 lines
1.1 KiB
Markdown
Raw Normal View History

2013-12-08 12:56:16 +04:00
# curl
> Transfers data from or to a server.
> Supports most protocols including HTTP, FTP, POP3.
2013-12-08 12:56:16 +04:00
- Download the contents of an URL to a file:
`curl {{http://example.com}} -o {{filename}}`
- Download a file saving the output under the filename indicated by the URL:
2013-12-08 12:56:16 +04:00
`curl -O {{http://example.com/filename}}`
2013-12-08 12:56:16 +04:00
2017-02-02 14:35:43 +03:00
- Download a file, following [L]ocation redirects, and automatically [C]ontinuing (resuming) a previous file transfer:
2013-12-08 12:56:16 +04:00
`curl -O -L -C - {{http://example.com/filename}}`
2013-12-08 12:56:16 +04:00
- Send form-encoded data (POST request of type application/x-www-form-urlencoded):
2013-12-08 12:56:16 +04:00
`curl -d {{'name=bob'}} {{http://example.com/form}}`
2013-12-08 12:56:16 +04:00
- Send data, specifying a custom HTTP method, and including an extra header:
2013-12-08 12:56:16 +04:00
`curl -d {{'{"name":"bob"}'}} -X {{PUT}} -H {{'Content-Type: application/json'}} {{http://example.com/users/1234}}`
2016-01-12 22:24:22 +03:00
- Pass a user name and password for server authentication and show headers info only:
2014-03-11 19:01:45 +04:00
`curl -u myusername:mypassword -I {{http://example.com}}`
2016-01-28 15:12:55 +03:00
- Pass client certificate and key for a secure resource:
`curl -v -key {{key.pem}} -cacert {{ca.pem}} -cert {{client.pem}} -k {{https://example.com}}`