Jmeter 之BeanShell 获取 header 以及 body
程序员文章站
2022-03-04 09:26:20
Jmeter使用,从body 中获取数据脚本代码import org.apache.jmeter.config.Arguments;import org.apache.jmeter.protocol.http.control.HeaderManager;import org.apache.jmeter.testelement.property.CollectionProperty;Arguments args = sampler.getArguments();HeaderM......
Jmeter使用,从body 中获取数据
脚本代码
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.http.control.HeaderManager;
import org.apache.jmeter.testelement.property.CollectionProperty;
Arguments args = sampler.getArguments();
HeaderManager headerManager = sampler.getHeaderManager();
String headers = "";
try{
headers = headerManager.getHeaders().getStringValue();
log.info("------------------------header------------------");
log.info("header : " + headers);
}
catch(Exception e){
log.info(e.getMessage());
}
String req_str = args.toString().replace("(", "").replace(")", "");
Map reqMap = args.getArgumentsAsMap();
log.info("------------------------body------------------");
for (String key : reqMap.keySet()) {
log.info("key: " + key + " , and value: " + reqMap.get(key));
}
本文地址:https://blog.csdn.net/wangxuelei036/article/details/107379569