>curl -h
Usage: curl [options...] <url>
-d, --data <data> HTTP POST data
-f, --fail Fail fast with no output on HTTP errors
-h, --help <category> Get help for commands
-i, --include Include protocol response headers in the output
-o, --output <file> Write to file instead of stdout
-O, --remote-name Write output to a file named as the remote file
-s, --silent Silent mode
-T, --upload-file <file> Transfer local FILE to destination
-u, --user <user:password> Server user and password
-A, --user-agent <name> Send User-Agent <name> to server
-v, --verbose Make the operation more talkative
-V, --version Show version number and quit
This is not the full help, this menu is stripped into categories.
Use "--help category" to get an overview of all categories.
For all options use the manual or "--help all".
上传和下载
curl -u [username]:[password] -k -T /tmp/xxx.tar.gz 'https://xxx.com/xxx.tar.gz'
其中,-T
参数表示上传文件,后面跟上本地文件路径。
将 -T
改为 -o
即可实现反过来下载。-o
参数表示下载文件,后面跟上本地文件保存路径。
-k
:忽略SSL证书验证,允许使用不安全的HTTPS连接。
request请求测试
curl --location --request POST 'https://xxx.com/get-file-list' \
--header 'key: 123456' \
--header 'secret: 123456' \
--header 'Content-Type: application/json' \
--data-raw '{
"account": "user1",
"password": "password1"
}'
可以直接导入postman: