public class HttpHeaders extends BaseConfigElement
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).
| Modifier and Type | Class and Description |
|---|---|
static class |
HttpHeaders.CodeBuilder |
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Object> |
headers |
guiClass, name| Constructor and Description |
|---|
HttpHeaders() |
| Modifier and Type | Method and Description |
|---|---|
protected org.apache.jmeter.testelement.TestElement |
buildTestElement() |
HttpHeaders |
contentType(org.apache.http.entity.ContentType contentType)
Allows to easily specify the Content-Type HTTP header.
|
HttpHeaders |
header(String name,
Class<? extends PropertyScriptBuilder.PropertyScript<String>> valueSupplierClass)
Same as
#header(String, PropertyScript) but with support for running at scale in a
remote engine. |
HttpHeaders |
header(String name,
PropertyScriptBuilder.PropertyScript<String> valueSupplier)
Same as
header(String, String) but allows using dynamically calculated HTTP header
value. |
HttpHeaders |
header(String name,
String value)
Allows to set an HTTP header to be used by HTTP samplers.
|
boolean |
isEmpty() |
buildConfiguredTestElement, buildTestElementGui, buildTreeUnder, configureTestElement, durationToSeconds, loadBeanProperties, showAndWaitFrameWith, showFrameWith, showInGui, showTestElementGuiclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuildTreeUnder, showInGuipublic HttpHeaders header(String name, String value)
To specify multiple headers just invoke this method several times with the different header names and values.
name - of the HTTP header.value - of the HTTP header.public HttpHeaders header(String name, PropertyScriptBuilder.PropertyScript<String> valueSupplier)
header(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.
name - of the HTTP header.valueSupplier - builds the header value.public HttpHeaders header(String name, Class<? extends PropertyScriptBuilder.PropertyScript<String>> valueSupplierClass)
#header(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.
PropertyScriptBuilder.PropertyScript,
#header(String, PropertyScript)public HttpHeaders contentType(org.apache.http.entity.ContentType contentType)
contentType - value to use as Content-Type header.public boolean isEmpty()
protected org.apache.jmeter.testelement.TestElement buildTestElement()
buildTestElement in class BaseTestElementCopyright © 2024. All rights reserved.