[linux] 使用curl排查接口问题
作者:互联网
当在浏览器请求接口速度很慢时 ,可以使用curl来进行测试
直接在浏览器 copy as cURL 就可以获取到curl的构建的完整命令参数
获取到curl后可以增加下面几个参数排查问题
-o /dev/null 不输出 -s 静默模式 -w 指定参数
curl 'https://jd.sopans.com/kefu/messages_page?pagesize=10&page=1&visitor_id=d0e980c2-731c-4184-a4a9-d67815386f9a' \ -H 'authority: jd.sopans.com' \ -H 'sec-ch-ua: " Not;A Brand";v="99", "Microsoft Edge";v="91", "Chromium";v="91"' \ -H 'accept: */*' \ -H 'x-requested-with: XMLHttpRequest' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36 Edg/91.0.864.48' \ -H 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVhdGVfdGltZSI6MTYyMzg5NTk3Niwia2VmdV9pZCI6NSwibmFtZSI6InRhb3NoaWhhbiIsInBpZCI6MSwicm9sZV9pZCI6MiwidHlwZSI6ImtlZnUifQ.RANitWYsg4BvoWMVgC1b6oUh4UYwHl_VaOTS036LZ48' \ -H 'sec-fetch-site: same-origin' \ -H 'sec-fetch-mode: cors' \ -H 'sec-fetch-dest: empty' \ -H 'referer: https://jd.sopans.com/chat_main' \ -H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6' \ -H 'cookie: Hm_lvt_82938760e00806c6c57adee91f39aa5e=1623402166,1623402182,1623891823,1623896035; Hm_lpvt_82938760e00806c6c57adee91f39aa5e=1623980536' \ --compressed \ -o /dev/null \ -s \ -w "time_connect: %{time_connect}\ntime_starttransfer:%{time_starttransfer}\ntime_nslookup:%{time_namelookup}\ntime_total: %{time_total}\n"
time_connect: 0.060
time_starttransfer:0.322
time_nslookup:0.029
time_total: 0.322
可以输出这几个 ,分别是连接时间,数据传输时间,dns解析时间,总时长
标签:en,linux,排查,sec,connect,time,sopans,curl 来源: https://blog.51cto.com/u_15274085/2966963