1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages/common/curl.md

38 lines
1.8 KiB
Markdown
Raw Normal View History

2013-12-08 19:56:16 +11:00
# curl
> Transfers data from or to a server.
> Supports most protocols, including HTTP, HTTPS, FTP, SCP, etc.
> More information: <https://curl.se/docs/manpage.html>.
2013-12-08 19:56:16 +11:00
- Make an HTTP GET request and dump the contents in `stdout`:
`curl {{https://example.com}}`
- Make an HTTP GET request, follow any `3xx` redirects, and dump the reply headers and contents to `stdout`:
2013-12-08 19:56:16 +11:00
`curl {{[-L|--location]}} {{[-D|--dump-header]}} - {{https://example.com}}`
2013-12-08 19:56:16 +11:00
- Download a file, saving the output under the filename indicated by the URL:
2013-12-08 19:56:16 +11:00
`curl {{[-O|--remote-name]}} {{https://example.com/filename.zip}}`
2013-12-08 19:56:16 +11:00
- Send form-encoded data (POST request of type `application/x-www-form-urlencoded`). Use `--data @file_name` or `--data @'-'` to read from `stdin`:
2013-12-08 19:56:16 +11:00
`curl {{[-X|--request]}} POST {{[-d|--data]}} {{'name=bob'}} {{http://example.com/form}}`
2013-12-08 19:56:16 +11:00
- Send a request with an extra header, using a custom HTTP method and over a proxy (such as BurpSuite), ignoring insecure self-signed certificates:
2013-12-08 19:56:16 +11:00
`curl {{[-k|--insecure]}} {{[-x|--proxy]}} {{http://127.0.0.1:8080}} {{[-H|--header]}} {{'Authorization: Bearer token'}} {{[-X|--request]}} {{GET|PUT|POST|DELETE|PATCH|...}} {{https://example.com}}`
- Send data in JSON format, specifying the appropriate Content-Type header:
`curl {{[-d|--data]}} {{'{"name":"bob"}'}} {{[-H|--header]}} {{'Content-Type: application/json'}} {{http://example.com/users/1234}}`
2016-01-12 11:24:22 -08:00
- Pass client certificate and key for a resource, skipping certificate validation:
2016-01-28 12:12:55 +00:00
`curl {{[-E|--cert]}} {{client.pem}} --key {{key.pem}} {{[-k|--insecure]}} {{https://example.com}}`
- Resolve a hostname to a custom IP address, with verbose output (similar to editing the `/etc/hosts` file for custom DNS resolution):
`curl {{[-v|--verbose]}} --resolve {{example.com}}:{{80}}:{{127.0.0.1}} {{http://example.com}}`