zoukankan      html  css  js  c++  java
  • loadrunner通过web的post请求方法测接口 2

    模拟APP发送请求给Cloud,
    一般都是用户登录后。cloud会返回登录成功的消息并且返回一个cookie给app,
    app下次要做一些例如设置名称之类的工作,在请求消息里面会携带返回的cookie,而且cloud也会校验这个cookie  
    1、第一次请求登录,获取cookie,
    2、使用第一次请求获取的cookie进行第二次请求

    Action()
    {

    web_reg_save_param("par1",
                             "LB=auth_key":"",
                             "RB="",
                             LAST);
    web_reg_save_param("par3",
     "LB=Set-Cookie: ",
     "RB=;",
     "ORD=2",
     LAST);

    web_reg_save_param("par4",
                             "LB=Set-Cookie: ",
                             "RB=;",
         "ORD=3",
                             LAST); 


    web_custom_request("login",
       "URL=http://192.168.1.102/api/user/login",
       "Method=POST",
       "Resource=0",
       "Referer=",
       "mode=HTTP",
       
       "Body=email=t993@163.com&password=8c2b2f9cd3431be8a7bf64a33e81b371",
       
                           LAST);


    lr_message ("par1:%s", lr_eval_string("{par1}"));

    lr_message ("par3:%s", lr_eval_string("{par3}"));
    lr_message ("par4:%s", lr_eval_string("{par4}"));


        
        return 0;
    }

    Action2()
    {

    web_cleanup_cookies();

    web_add_header("cookie",
       "{par3};{par4};{par1}");


    web_custom_request("info",
       "URL=http://192.168.1.102/api/app/set/device",
       "Method=POST",
       "Resource=0",
       "Referer=",
       "mode=HTTP",
       
       "Body=camid=4026aabz&auth_key={par1}",
       LAST);
    return 0;
    }


    传json数据时引号前加转义字符
     "Name=input","Value={"mobile":"15280288286","password":"6f96c57e306923c7"}",ENDITEM,
  • 相关阅读:
    POJ 1703 Find them, Catch them
    POJ 2236 Wireless Network
    POJ 2010 Moo University
    POJ 2184 Cow Exhibition
    POJ 3280 Cheapest Palindrome
    POJ 3009 Curling 2.0
    POJ 3669 Meteor Shower
    POJ 2718 Smallest Difference
    POJ 3187 Backward Digit Sums
    POJ 3050 Hopscotch
  • 原文地址:https://www.cnblogs.com/finer/p/11895359.html
Copyright © 2011-2022 走看看