美文网首页
eg:LoadRunner处理请求头部信息

eg:LoadRunner处理请求头部信息

作者: 丹丹后院 | 来源:发表于2017-10-21 20:46 被阅读0次

    header案例

    接口业务:获取用户信息

    接口内容 http://123.58.251.183:8080/goods/json2

    头信息 "token":"61b3590090982a0185dda9d3bd793b46"

    接口请求 {"count":5}

    返回值

    成功 {"code":"1","data":[{"name":"testfan0","pwd":"pwd0"},{"name":"testfan1","pwd":"pwd1"}]}

    失败  {"msg":"token验证错误,无权限","code":"0"}

    提取所有 name

    ------------------------------------------------

    Action()

    {

    int size;

    int i;

    web_reg_save_param("namelist",

    "LB=\"name\":\"",

    "RB=\",",

    "Ord=ALL",

    LAST);

    web_add_header("token","61b3590090982a0185dda9d3bd793b46");

    web_custom_request("web_custom_request",

    "URL=http://123.58.251.183:8080/goods/json2",

    "Method=post",

    "TargetFrame=",

    "Resource=0",

    "Referer=",

    "Mode=HTTP",

    "RecContentType=application/json;charset=UTF-8",  //指定响应头(接收)的Content-Type,这里是"JSON"

    "EncType=application/json;charset=UTF-8",  //指定请求头的Content-Type,这里也是“JSON”

    "Body={\"count\":3}",

    LAST);

    size = lr_paramarr_len("namelist");

    lr_output_message("size is %d",size);

    for(i=1;i<=size;i++){

    lr_output_message("name is %s",lr_paramarr_idx("namelist",i));

    }

    return 0;

    }

    相关文章

      网友评论

          本文标题:eg:LoadRunner处理请求头部信息

          本文链接:https://www.haomeiwen.com/subject/mdnkjxtx.html