首页 笔记 图片 查字 
所属分类:Linux
浏览:108
内容:

1、curl -k  
允许curl使用非安全的ssl连接并且传输数据(证书不受信)
再发送https请求时,加上-k参数,否则会有如下证书的报错

curl: (60) Peer's certificate issuer has been marked as not trusted by the user.
More details here: http://curl.haxx.se/docs/sslcerts.html

2、curl -X(大写)
指定请求方法,如POST、GET等
curl -k -X POST "https://www.baidu.com"

3、 curl -w %{http_code}
返回值带上http响应码
curl -k -w %{http_code} -X POST "https://localhost:8088/"

4、curl -d
用于post请求时表单提交数据, 请求类型将被设置为:application/x-www-form-urlencoded
curl -k -w %{http_code} -X POST "https://localhost:8088/" -d 'body内容' (内容需要用单引号括起来)

5、curl -H
header头内容
curl -k -w %{http_code} -X POST "https://localhost:8088/" -d 'body内容' -H 'header内容'

6、-F
body带文件,form表单提交
curl -k -X POST "https://localhost:8088/" -F 'file=@file_path'

7、-u
用户名和密码

例子:
[root@local]  curl -u user_name:password -k -X GET "https://localhost:8088/v1/cluster/metrics"