curl调试web/cgi

5 篇文章 0 订阅
#! /bin/bash
#

URL='http://192.168.20.127/cgi-bin/lig_switch.cgi'
cat <<EOF | while read  line
query={"name":"switch","data":{"attribute_name":"port","type":"v","index":0}}
query={"name":"switch","data":{"attribute_name":"xxx","type":"v","index":0}}
query={"name":"switch","data":{"type":"v","index":0}}
query={"name":"switch","data":{"attribute_name":"routing","type":"v","index":0}}
query={"name":"switch","data":{"attribute_name":"xxx","type":"v","index":0}}
query={"name":"switch","data":{"xxx":"routing","type":"v","index":0}}
query={"name":"switch","data":{"attribute_name":"port_cfg","type":"v","index":1}}
query={"name":"switch","data":{"attribute_name":"xxx","type":"v","index":1}}
query={"name":"switch","data":{"xxxxx":"port_cfg","type":"v","index":1}}
update={"name":"switch","data":{"port_cfg":{"index":1,"dir":"in","type":"v","title":"ROOM-SIG_1","HDCP_mode":{"sid":155,"value":0}}}}
update={"name":"switch","data":{"xxx":{"index":1,"dir":"in","type":"v","title":"ROOM-SIG_1","HDCP_mode":{"sid":155,"value":0}}}}
update={"name":"switch","data":{"port_cfg":{"index":1,"dir":"out","type":"v","title":"ROOM-TV-1","SwitchSpeed":{"sid":75,"value":1}}}}
update={"name":"switch","data":{"12345456":{"index":1,"dir":"out","type":"v","title":"ROOM-TV-1","SwitchSpeed":{"sid":75,"value":1}}}}
EOF
do
	echo -e "\e[32;1m$line\e[0m "
	curl --silent -G --data $line ${URL} | json_pp -f json -t json
done

curl -i -G --trace-time --data ‘query={“name”:“switch”,“data”:{“attribute_name”:“port_cfg”,“type”:“v”,“index”:1}}’ http://192.168.20.127/cgi-bin/lig_switch.cgi -o log

-i/–include 输出时包括protocol头信息
-G/–get 以get的方式来发送数据
–trace 对指定文件进行debug
–trace-ascii Like --跟踪但没有hex输出
–trace-time 跟踪/详细输出时,添加时间戳

–data
-o/–output 把输出写到该文件中
-O/–remote-name 把输出写到该文件中,保留远程文件的文件名

-d/–data HTTP POST方式传送数据
–data-ascii 以ascii的方式post数据
–data-binary 以二进制的方式post数据
–negotiate 使用HTTP身份验证
–digest 使用数字身份验证
–disable-eprt 禁止使用EPRT或LPRT
–disable-epsv 禁止使用EPSV

curl -G --data 'query={"name":"switch","data":{"attribute_name":"port_cfg","type":"v","index":1}}'  http://192.168.20.127/cgi-bin/lig_switch.cgi | json_pp 


  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   117    0   117    0     0   5625      0 --:--:-- --:--:-- --:--:--  5850
{
   "status" : "failed",
   "name" : "switch",
   "data" : {
      "test" : "for example",
      "index" : 1,
      "type" : "v",
      "attribute_name" : "port_cfg"
   }
}

可以在git bash中运行(windows)

curl --silent -G --data 'query={"name":"switch","data":{"attribute_name":"port_cfg","type":"v","index":1}}'  http://192.168.20.127/cgi-bin/lig_switch.cgi | json_pp -f json -t json
{
   "data" : {
      "attribute_name" : "port_cfg",
      "test" : "for example",
      "type" : "v",
      "index" : 1
   },
   "name" : "switch",
   "status" : "failed"
}

1、vim curl

\n 
       time_namelookup:  %{time_namelookup}\n
               time_connect:  %{time_connect}\n
            time_appconnect:  %{time_appconnect}\n
           time_pretransfer:  %{time_pretransfer}\n
              time_redirect:  %{time_redirect}\n
         time_starttransfer:  %{time_starttransfer}\n
                            ----------\n
                 time_total:  %{time_total}\n
\n

time_namelookup:DNS解析域名时间,把域名—>ipd的时间
time_connect:TCP连接的时间,三次握手的时间
time_appconnect:SSL|SSH等上层连接建立的时间
time_pretransfer:从请求开始到到响应开始传输的时间
time_redirect:从开始到最后一个请求事务的时间
time_starttransfer:从请求开始到第一个字节将要传输的时间
time_total:总时间

2、eg

 curl -w "@curl.conf" --silent -G --data 'query={"name":"switch","data":{"attribute_name":"port_cfg","type":"v","index":1}}'  http://192.168.20.127/cgi-bin/lig_switch.cgi
{"status":"failed","name":"switch","data":{"attribute_name":"port_cfg","index":1,"test":"for example","type":"v"}
}


        time_namelookup:  0.000001
               time_connect:  0.015000
            time_appconnect:  0.000000
           time_pretransfer:  0.015000
              time_redirect:  0.000000
         time_starttransfer:  0.031000
                            ----------
                 time_total:  0.031000

3、简单的方式
curl -o /dev/null -s -w '%{time_connect}:%{time_starttransfer}:%{time_total}\n' 'http://www.baidu.com'
4、 post方式传输文件

curl -i -X POST --trace-time http://192.168.20.110/cgi-bin/upload.cgi -F "file=@//home/alex/Git_repo/CPMS-34/VS-34FD_xx.xx.xxxx.kptw"  -v
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值