80 lines
1.2 KiB
Markdown
80 lines
1.2 KiB
Markdown
---
|
|
title: Curl
|
|
category: CLI
|
|
layout: 2017/sheet
|
|
updated: 2017-09-20
|
|
---
|
|
|
|
## Options
|
|
|
|
### Options
|
|
|
|
```bash
|
|
-o <file> # --output: write to file
|
|
-u user:pass # --user: Authentication
|
|
```
|
|
|
|
```bash
|
|
-v # --verbose
|
|
-vv # Even more verbose
|
|
```
|
|
|
|
```bash
|
|
-I # --head: headers only
|
|
```
|
|
|
|
### Request
|
|
|
|
```bash
|
|
-X POST # --request
|
|
```
|
|
|
|
### Data
|
|
|
|
```bash
|
|
-d 'data' # --data: HTTP post data, URL encoded (eg, status="Hello")
|
|
-d @file # --data via file
|
|
-G # --get: send -d data via get
|
|
```
|
|
|
|
### Headers
|
|
|
|
```bash
|
|
-A <str> # --user-agent
|
|
-b name=val # --cookie
|
|
-b FILE # --cookie
|
|
-H "X-Foo: y" # --header
|
|
--compressed # use deflate/gzip
|
|
```
|
|
|
|
### SSL
|
|
|
|
```bash
|
|
--cacert <file>
|
|
--capath <dir>
|
|
```
|
|
|
|
```bash
|
|
-E, --ecrt <cert> # --ecrt: Client cert file
|
|
--cert-type # der/pem/eng
|
|
-k, --insecure # for self-signed certs
|
|
```
|
|
|
|
## Examples
|
|
{: .-one-column}
|
|
|
|
```bash
|
|
# Post data:
|
|
curl -d password=x http://x.com/y
|
|
```
|
|
|
|
```bash
|
|
# Auth/data:
|
|
curl -u user:pass -d status="Hello" http://twitter.com/statuses/update.xml
|
|
```
|
|
|
|
```bash
|
|
# multipart file upload
|
|
curl -v -include --form key1=value1 --form upload=@localfilename URL
|
|
```
|