使用curl进行网络诊断
上一篇 / 下一篇 2012-02-26 16:46:31 / 个人分类:自动化测试
文章来源
- 文章来源:【转载】
我们使用浏览器插件,很容易查看到网页细分请求消耗的时间。如Firefox的Firebug插件:51Testing软件测试网1B7fs9A4K-`
51Testing软件测试网fB`.qv"s-ft)Y?v;K51Testing软件测试网\[1uSC2@[
Linux的命令行怎样实现类似功能呢?curl即可实现:
%X&f"Ub!p7Q!PX0/usr/bin/curl --no-keepalive --no-sessionid --noproxy -o /dev/null -s
-w'time_namelookup=%{time_namelookup}
Hp
}J,[ {*u0time_connect=%{time_connect}
0d:lDg
m0time_appconnect=%{time_appconnect}
V
R;WUP F/G0time_pretransfer=%{time_pretransfer}
m&{(T)p+J'z:s(i9}0time_redirect=%{time_redirect}
/f&~)Kk*e9FSth0time_starttransfer=%{time_starttransfer}51Testing软件测试网%Vp*[@MD%h6r
size_download=%{size_download}51Testing软件测试网0O!i0xX'V*\3R}
size_upload=%{size_upload}
H-e{+f2lvU/~:BA0size_header=%{size_header}
(L,qN~9i7cQ0size_request=%{size_request}51Testing软件测试网]%^L{E7TwH o
speed_download=%{speed_download}51Testing软件测试网
G7Xc7El
speed_upload=%{speed_upload}51Testing软件测试网9GLVt0n
{6m2VK'`W#o~
content_type=%{content_type}51Testing软件测试网W}hxU/r4N4J*Ww
num_connects=%{num_connects}
]:u)dkM0num_redirects=%{num_redirects}51Testing软件测试网 {/m~ U)?3R OBfo
redirect_url=%{redirect_url}51Testing软件测试网R"dp+J-E'WQ
time_total=%{time_total}\n'http://www.baidu.com/img/baidu_sylogo1.gif
-v --trace-time51Testing软件测试网5c?7N2hPc3Nxi
h-Lk
"Q)\,Dg#ux%q0获取结果如下:51Testing软件测试网q9Ik6}+Ix0f%l'p
51Testing软件测试网o"Q5zY.Jt51Testing软件测试网:r:?2byZC
J{(\LI5`"Z |3C004:15:55.518146 * About to connect() to www.baidu.com port 80 (#0)
pw6b7wr0\J(ZM _LO]J*k004:15:55.518227 * Trying 220.181.112.143... connected
O9qaj3y051Testing软件测试网2Z C2kQ]D04:15:55.556297 * Connected to www.baidu.com (220.181.112.143) port 80 (#0)51Testing软件测试网~U9k(?F\ |"\&Em#T?
3k[Z/@C |c004:15:55.556379 > GET /img/baidu_sylogo1.gif HTTP/1.151Testing软件测试网,h9T(G|(oj{*O"i'D&Zd
(Vvg3Z {}8C?004:15:55.556379 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.12.7.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.251Testing软件测试网0M[ _1d4o0^)\
k"Q G$\KdN4|004:15:55.556379 > Host: www.baidu.com51Testing软件测试网!t R2Zu1NF$J+v
9f$WpF2f ^GV)g004:15:55.556379 > Accept: */*51Testing软件测试网N6}pr"gn%r
,wW\X_{c@004:15:55.556379 >51Testing软件测试网~2y`?0R9b%M?6jP
B7WZu`]X#[ Up004:15:55.597388 < HTTP/1.1 200 OK51Testing软件测试网T Oq~b%B[[$G