eg:LoadRunner处理请求头部信息

2017-10-21  本文已影响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;

}

上一篇下一篇

猜你喜欢

热点阅读