loadrunner获取接口返回参数(包括body,headers等)

Action()
{
  web_set_max_html_param_len("262144"); // 默认最大长度为256
  web_reg_save_param("ResponseBody", "LB=", "RB=", "Search=Body", LAST);
  web_save_header(REQUEST, "RequestHeader");// REQUEST为内置变量,保存请求的头信息,需在发送URL请求前注册使用,将请求头信息存入字符串RequestHeader中
  web_save_header(RESPONSE, "ResponseHeader");// 将RESPONSE保存响应的头信息在字符串ResponseHeader中

  web_url("blog",
      "URL=http://blog.sina.com.cn/bestfeiyong",
      "Resource=0",
      "RecContentType=text/html",
      "Mode=HTTP",
  LAST);
  //字符转码
lr_convert_string_encoding(lr_eval_string("{RequestHeader}"),LR_ENC_UTF8 ,LR_ENC_SYSTEM_LOCALE,"RequestHeaderUTF8");
lr_convert_string_encoding(lr_eval_string("{ResponseHeader}"),LR_ENC_UTF8 ,LR_ENC_SYSTEM_LOCALE,"ResponseHeaderUTF8");
lr_convert_string_encoding(lr_eval_string("{ResponseBody}"),LR_ENC_UTF8 ,LR_ENC_SYSTEM_LOCALE,"ResponseBodyUTF8");
  //输出信息
  lr_output_message("# 请求头信息:\n %s", lr_eval_string("{RequestHeaderUTF8}"));
  lr_output_message("# 响应头信息:\n %s", lr_eval_string("{ResponseHeaderUTF8}"));
  lr_output_message("# 响应内容体:\n %s", lr_eval_string("{ResponseBodyUTF8}"));
return 0;
}

 

转载于:https://www.cnblogs.com/JHblogs/p/7778518.html

你可能感兴趣的:(postman,json)