部分參數
-
-d, --data <data>
POST的包體
-
-H, --header <header>
包頭
-
-w, --write-out <format>
耗時時間
-
-X, --request
發送方式(POST、PUT)
舉例
POST application/x-www-form-urlencoded
curl -d "param1=value1¶m2=value2" -X POST http://localhost:8080/hello
curl -d "param1=value1¶m2=value2" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:8080/hello
#使用文件
curl -d "@../data/cats.txt" -X POST http://localhost:8080/hello
POST application/json
curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST http://localhost:8080/hello
curl -d "@../data/cats.txt" -X POST http://localhost:8080/hello
測試訪問支付寶首頁
# 環境
$ lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.5 (Final)
Release: 6.5
Codename: Final
# 測試
$ curl -w "TCP handshake: %{time_connect}, SSL handshake: %{time_appconnect}\n" -so /dev/null https://www.alipay.com
TCP handshake: 0.141, SSL handshake: 0.435
參考