所有請求最好都加上單引號嗜暴,否則對于一些特性字符,會被轉(zhuǎn)義掉
- get請求r
curl 'http://xxxx'
- 顯示請求頭孵淘、響應(yīng)頭: -v
curl -v 'xxxx'
- 設(shè)置請求頭:-H 或者 --header
curl -H 'Host: 157.166.226.25' -H 'Accept-Language: es' -H 'Cookie: ID=1234' http://cnn.com
- post請求:-d
curl -d 'name=wangyong' 'xxxx'
- 顯示接口請求時間:-w '%{time_total}'
curl -w '\ntimeTotal:%{time_total}\n' 'http://localhost:8080/appinfo/v1/app/ext/getSecInfo?appId=114703'
將輸出結(jié)果寫入文件或丟棄:-o 文件名 / -o /dev/null
如果url中有{} [] ,加-g
否則報錯 curl: (3) [globbing] error:
Linux有問必答:如何在curl中設(shè)置自定義的HTTP頭
用curl命令來測試網(wǎng)頁響應(yīng)時間
curl: (3) [globbing] error: bad range specification after pos 150的解決方法