i have a test plan that has 50 http sampler ( API testing ) i want 1 http sampler to use header manager of its own(ie specefic to the sampler) and other 49 to use global header manager (common) ( i dont want to add header manager for every http sampler)
attached image Login request has its own header manager, when i add a global header manager, login sampler takes both global header details and its own header details how can i make login sampler to use only headers from its child header manager and not common?
How can i make http samplers to use headers of its own( child or same level) and not common or how can i override the common header manager?
As per JMeter documentation :
JMeter now supports multiple Header Managers. The header entries are merged to form the list for the sampler . If an entry to be merged matches an existing header name, it replaces the previous entry. This allows one to set up a default set of headers, and apply adjustments to particular samplers. Note that an empty value for a header does not remove an existing header, it justs replace its value.
So there is only one HTTP Header Manager containing combined headers from the top-level one and with the one which is the child of the current sampler.
If you want to remove all headers which are set by the top-level header manager - you need to add a JSR223 PreProcessor and do it there. New headers can be added in the same JSR223 PreProcessor if needed.
Example code:
import org.apache.jmeter.protocol.http.control.Header
sampler.getHeaderManager().clear()
sampler.getHeaderManager().add(new Header('header1','value1'))
sampler.getHeaderManager().add(new Header('header2','value2'))
More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.