1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Usage: curl [options...] <url>
-X, --request <method> 设置请求方法
-d, --data <data> POST data
-H, --header <header> 设置请求头
-A, --user-agent <name> 设置User-Agent
-b, --cookie <data|file> 设置Cookie
-u, --user <user:passwd> Server user and passwd
-I, --head 输出响应头
-i, --include 输出响应包
-o, --output <file> 写入文件
-O, --remote-name 下载文件
-T, --upload-file <file> 上传文件(PUT)
-F, --form <file=@/file;type=*;filename=*; | field=value> 上传文件(POST)
-s, --silent Silent mode, 无进度或错误信息
-k, --insecure 忽略 SSL 证书验证
-L, --location 跟随重定向
-v, --verbose 显示详细信息
--http2 启用HTTP/2支持
--retry <1-5> 设置重试次数
--max-time <seconds> 设置执行超时时间
--connect-timeout <seconds> 设置连接超时时间
--trace - 查看请求的所有细节 (包括请求体和响应体)
-x, --proxy <<http|socks5>://[user:passwd@]host:port> 设置代理
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 上传表单
curl -X POST -F "file=@/path/to/your/file.txt" http://example.com/upload
# [-H "Content-Type: multipart/form-data"]
# -F 选项会自动设置 Content-Type: multipart/form-data

# 上传多个表单
curl -X POST -F "file1=@/path/to/file1.txt" -F "file2=@/path/to/file2.txt" http://example.com/upload

# 上传流文件
curl -X POST --data-binary @/path/to/file.bin http://example.com/upload
# [-H "Content-Type: application/octet-stream"]

# Json格式
curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' http://example.com/api

# data数据
curl -X POST -d "key1=value1&key2=value2" http://example.com/api

# 授权请求头
-H "Authorization: Bearer YOUR_TOKEN"

2024-09-07
Contents

⬆︎TOP