<返回更多

Linux系统curl命令使用方法汇总

2023-07-27  今日头条  寒笛过霜天
加入收藏

yum install -y libcurl-dev

上传文件

curl -F "file=@D:/list.txt" "http://43.254.156.147:10001/files?username=tipdm&course=hadoop%E5%9F%BA%E7%A1%80&chart=hadoop&path=test"

curl -F 'file=@/home/info.txt' '43.254.156.147:10001/files?username=tipdm&course=hadoop%E5%9F%BA%E7%A1%80&chart=hadoop&path=test'

其他调用方法:

curl -X POST -d "username=chengy2&course=hadoop&chart=hadoop&version=1.0.3" http://172.16.14.38:10001/createCluster

curl -X PUT "http://172.16.14.38:10001/stopCluster?username=chengy2&course=hadoop&chart=hadoop"

curl -X DELETE "http://172.16.14.38:10001/deleteCluster?username=chengy2&course=hadoop&chart=hadoop"

curl "http://172.16.14.38:10001/clusterInfo?username=chengy3&course=hadoop&chart=hadoop"

传递多个请求头参数

curl -X POST

-H "Content-Type: Application/json"

-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBbGxvdyI6WyJyZWFkIl19.SX19fBM7V3Xa7rJf6wmCPwMexWDQBZkbHVs0Qsjx3iQ"

--data '{

"jsonrpc":"2.0",

"method":"Filecoin.StateMinerPower",

"params":["f033130",[]],

"id":123

}'

'http://183.24.157.154:21063/rpc/v0'

 

下载文件

curl "http://172.16.14.38:10001/downloadFile?username=chengy3&course=hadoop&chart=hadoop&file=test/xxx"

单文件上传

curl -X POST http://localhost:8080/upload -F "file=@/Users/appleboy/test.zip" -H "Content-Type: multipart/form-data"

curl -X POST http://localhost:8080/upload -F "file=@E:/www.online.com-1576659729584.log" -H "Content-Type: multipart/form-data"

多文件上传

curl -X POST http://localhost:8080/upload -F "upload[]=@/Users/appleboy/test1.zip" -F "upload[]=@/Users/appleboy/test2.zip" -H "Content-Type: multipart/form-data"

curl -X POST http://localhost:8080/upload -F "files[]=@E:/www.online.com-1576659729584.log" -F "files[]=@E:/www.online.com-1576658873471.log" -H "Content-Type: multipart/form-data"

SSL证书访问

curl --cert "configs/tls/prod/client.crt" --key "configs/tls/prod/client.key" https://127.0.0.1:1216/rpc

curl -i -k https://localhost:4431/

注意:

-k 用户忽略证书验证, 否则你需要通过 --cacert 指定 CA 证书位置;

-i 在输出中包括协议响应头;

curl支持HTTP3协议的方法:

https://Github.com/curl/curl/blob/master/docs/HTTP3.md

声明:本站部分内容来自互联网,如有版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
▍相关推荐
更多资讯 >>>