经常使用linux的同学会发现有时使用浏览器url调试不如使用linux下的curl命令请求来的方便快一些,下面是在
命令行界面下curl的使用:
带上-v参数 -v
参数可以显示一次 http 通信的整个过程,包括端口连接和 http request 头信息
curl -v https://weixin.shangdatong.com/weichat/message?id=48
* subject: CN=weixin.shangdatong.com
* start date: Apr 17 00:00:00 2019 GMT
* expire date: Apr 16 12:00:00 2020 GMT
* subjectAltName: host "weixin.shangdatong.com" matched cert's "weixin.shangdatong.com"
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=Encryption Everywhere DV TLS CA - G1
* SSL certificate verify ok.
> GET /weichat/message?id=48 HTTP/1.1
> Host: weixin.shangdatong.com
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.10.2
< Date: Mon, 21 Oct 2019 22:43:52 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Powered-By: PHP/7.0.7
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: X-Requested-With
< Access-Control-Allow-Methods: GET,POST,OPTIONS
<
* Connection #0 to host weixin.shangdatong.com left intact
curl发送Post请求
curl curl -v https://weixin.shangdatong.com/weichat/message?id=48 -X POST -d ‘test1=1&test2=2’
* subjectAltName: host "weixin.shangdatong.com" matched cert's "weixin.shangdatong.com"
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=Encryption Everywhere DV TLS CA - G1
* SSL certificate verify ok.
> POST /weichat/message?id=48 HTTP/1.1
> Host: weixin.shangdatong.com
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Length: 15
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 15 out of 15 bytes
< HTTP/1.1 200 OK
< Server: nginx/1.10.2
< Date: Mon, 21 Oct 2019 22:47:06 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Powered-By: PHP/7.0.7
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: X-Requested-With
< Access-Control-Allow-Methods: GET,POST,OPTIONS
<
* Connection #0 to host weixin.shangdatong.com left intact