curl http header_Linux 常见命令 curl的高级用法---curl 格式化输出

Linux 常见命令 curl的高级用法---curl 格式化输出

前言

Curl 命令是在运维过程中,非常常见的命令,cURL是一个利用URL语法在命令行下工作的文件传输工具,1997年首次发行。它支持文件上传和下载,所以是综合传输工具,但按传统,习惯称cURL为下载工具。cURL还包含了用于程序开发的libcurl。

cURL支持的通信协议有FTP、FTPS、HTTP、HTTPS、TFTP、SFTP、Gopher、SCP、Telnet、DICT、FILE、LDAP、LDAPS、IMAP、POP3、SMTP和RTSP。

curl还支持SSL认证、HTTP POST、HTTP PUT、FTP上传, HTTP form based upload、proxies、HTTP/2、cookies、用户名+密码认证(Basic, Plain, Digest, CRAM-MD5, NTLM, Negotiate and Kerberos)、file transfer resume、proxy tunneling。

在使用时,会希望获取更多的信息,比如请求耗时,访问时延,请求大小等相关参数,虽然配合其他命令也可以实现该效果,比如time 命令配合curl命令公共使用,不过还是不够方便,可以使用curl 命令的格式化输出的功能,配置显示格式。

官文文档:

https://curl.haxx.se/docs/manpage.html

使用说明

官网解释:

8eac2db19d307afced7a90aaad4beba9.png

实际操作:

[root@elb handle_log]# cat format_curl.txt time_namelookup: %{time_namelookup} time_connect: %{time_connect} time_appconnect: %{time_appconnect} time_pretransfer: %{time_pretransfer} time_redirect: %{time_redirect} time_starttransfer: %{time_starttransfer} ---------- time_total: %{time_total} http_code: %{http_code} ---------- local_ip: %{local_ip} size_download: %{size_download} size_header: %{size_header} size_request: %{size_request} size_upload: %{size_upload} speed_download: %{speed_download} speed_upload: %{speed_upload}[root@elb handle_log]# ls
ca4680f5928ff3d6109620d2993ae20f.png

使用测试:

curl -w "@format_curl.txt" http://XX.XX.91.152:9090/graph -o /dev/null
4e084a1e31f15b3031a4f7dd93aff5ba.png
ab7d32acaca3a90d0c7e12878d3e53a8.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值