[英]jmeter Beanshell PostProcessor remove header throws exception
When I was using BeanShell PostProcessor to delete the header,there is a problem my code: 当我使用BeanShell PostProcessor删除标题时,我的代码存在问题:
import org.apache.jmeter.protocol.http.control.Header;
sampler.getHeaderManager().removeHeaderNamed("Authorization");
exception: 例外:
2017/05/18 15:24:52 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.apache.jmeter.protocol.http.control.Header; sampler.getHeaderManage . . . '' : Attempt to resolve method: getHeaderManager() on undefined variable or class name: sampler
2017/05/18 15:24:52 WARN - jmeter.extractor.BeanShellPostProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.apache.jmeter.protocol.http.control.Header; sampler.getHeaderManage . . . '' : Attempt to resolve method: getHeaderManager() on undefined variable or class name: sampler
somebody help me 来人帮帮我
You don't have sampler
shorthand in the PostProcessor, if you need to remove the header from the previous sampler the relevant code should look like: 您在PostProcessor中没有
sampler
简写形式,如果您需要从先前的采样器中删除标头,则相关代码应如下所示:
ctx.getCurrentSampler().getHeaderManager().removeHeaderNamed("Authorization");
ctx
is a shorthand to JMeterContext class instance ctx
是JMeterContext类实例的简写 sampler
shorthand sampler
速记
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.