Class HttpHeaders
- java.lang.Object
-
- us.abstracta.jmeter.javadsl.core.testelements.BaseTestElement
-
- us.abstracta.jmeter.javadsl.core.configs.BaseConfigElement
-
- us.abstracta.jmeter.javadsl.http.HttpHeaders
-
- All Implemented Interfaces:
DslConfig,DslTestElement,DslTestPlan.TestPlanChild,BaseSampler.SamplerChild,MultiLevelTestElement,BaseThreadGroup.ThreadGroupChild
public class HttpHeaders extends BaseConfigElement
Allows specifying HTTP headers (through an underlying JMeter HttpHeaderManager) to be used by HTTP samplers.This test element can be added at different levels (in the same way as HTTPHeaderManager) of a test plan affecting all samplers in the scope were is added. For example if httpHeaders is specified at test plan, then all headers will apply to http samplers; if it is specified on thread group, then only samplers on that thread group would be affected; if specified as a child of a sampler, only the particular sampler will include such headers. Also take into consideration that headers specified at lower scope will overwrite ones specified at higher scope (eg: sampler child headers will overwrite test plan headers).
- Since:
- 0.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHttpHeaders.CodeBuilder
-
Constructor Summary
Constructors Constructor Description HttpHeaders()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.jmeter.testelement.TestElementbuildTestElement()HttpHeaderscontentType(org.apache.http.entity.ContentType contentType)Allows to easily specify the Content-Type HTTP header.HttpHeadersheader(String name, Class<? extends PropertyScriptBuilder.PropertyScript<String>> valueSupplierClass)Same asheader(String, PropertyScript)but with support for running at scale in a remote engine.HttpHeadersheader(String name, String value)Allows to set an HTTP header to be used by HTTP samplers.HttpHeadersheader(String name, PropertyScriptBuilder.PropertyScript<String> valueSupplier)Same asheader(String, String)but allows using dynamically calculated HTTP header value.booleanisEmpty()-
Methods inherited from class us.abstracta.jmeter.javadsl.core.testelements.BaseTestElement
buildConfiguredTestElement, buildTestElementGui, buildTreeUnder, configureTestElement, durationToSeconds, loadBeanProperties, showAndWaitFrameWith, showFrameWith, showInGui, showTestElementGui
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface us.abstracta.jmeter.javadsl.core.DslTestElement
buildTreeUnder, showInGui
-
-
-
-
Method Detail
-
header
public HttpHeaders header(String name, String value)
Allows to set an HTTP header to be used by HTTP samplers.To specify multiple headers just invoke this method several times with the different header names and values.
- Parameters:
name- of the HTTP header.value- of the HTTP header.- Returns:
- the config element for further configuration or usage.
-
header
public HttpHeaders header(String name, PropertyScriptBuilder.PropertyScript<String> valueSupplier)
Same asheader(String, String)but allows using dynamically calculated HTTP header value.This method is just an abstraction that uses jexl2 function as HTTP header value.
WARNING: This only works when using embedded jmeter engine. Check the user guide for details on some alternative.
- Parameters:
name- of the HTTP header.valueSupplier- builds the header value.- Returns:
- the config element for further configuration or usage.
- Since:
- 1.14
-
header
public HttpHeaders header(String name, Class<? extends PropertyScriptBuilder.PropertyScript<String>> valueSupplierClass)
Same asheader(String, PropertyScript)but with support for running at scale in a remote engine.Check the user guide for details on additional steps required to run them at scale in a remote engine.
- Since:
- 1.14
- See Also:
PropertyScriptBuilder.PropertyScript,header(String, PropertyScript)
-
contentType
public HttpHeaders contentType(org.apache.http.entity.ContentType contentType)
Allows to easily specify the Content-Type HTTP header.- Parameters:
contentType- value to use as Content-Type header.- Returns:
- the config element for further configuration or usage.
- Since:
- 0.42
-
isEmpty
public boolean isEmpty()
-
buildTestElement
protected org.apache.jmeter.testelement.TestElement buildTestElement()
- Specified by:
buildTestElementin classBaseTestElement
-
-