tldr/pages/common/curl.md

33 lines
1.1 KiB
Markdown
Raw Normal View History

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