curl使用技巧

  • 打印dns解析时间,响应时间,传输时间等
curl -o /dev/null -s -w 'http_code:%{http_code}| http_connect:%{http_connect}| time_namelookup:%{time_namelookup}| time_connect:%{time_connect}| time_pretransfer:%{time_pretransfer}| time_starttransfer:%{time_starttransfer}| time_total:%{time_total}| size_download:%{size_download}| speed_download:%{speed_download}'  www.baidu.com

curl -o /dev/null -s -w '状态码:%{http_code}| http连接耗时:%{http_connect}| 域名解释耗时:%{time_namelookup}| 连接耗时:%{time_connect}| 预传输耗时:%{time_pretransfer}| 开始传输耗时:%{time_starttransfer}| 总耗时:%{time_total}| 下载大小:%{size_download}| 下载速度:%{speed_download}'  www.baidu.com


curl -o /dev/null --connect-timeout 10 -m 10 -N -s -w 'Http_code %{http_code}\nhttp_connect %{http_connect}\nDnslookup_time %{time_namelookup}\nConnect_time %{time_connect}\nPretransfer_time %{time_pretransfer}\nStarttransfer_time %{time_starttransfer}\nTotal_time %{time_total}\nDownload_size %{size_download}\nDownload_speed %{speed_download}\n'  www.baidu.com 

Http_code 200
http_connect 000
Dnslookup_time 0.014
Connect_time 0.021
Pretransfer_time 0.021
Starttransfer_time 0.029
Total_time 0.029
Download_size 2381
Download_speed 81038.000
  • 使用curl访问unix-socket

例如 ingress-nginx 的监听地址为 unix:/tmp/nginx-status-server.sock 。

server {
        listen unix:/tmp/nginx-status-server.sock;
        set $proxy_upstream_name "internal";
 
        keepalive_timeout 0;
        gzip off;
 
        access_log off;
 
        location /healthz {
                return 200;
        }
 
        location /nginx_status {
                stub_status on;
        }
        ... 省略...
}

用 curl 访问它的 Unix Socket 的方法如下:

curl --unix-socket /tmp/nginx-status-server.sock http://localhost/nginx_status
Active connections: 77
server accepts handled requests
 64273 64273 971368
Reading: 0 Writing: 12 Waiting: 65

curl 在7.21以后才支持SNI访问

curl -vik --resolve dc.gdgov.cn:443:127.0.0.1 https://dc.gdgov.cn
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值