public class DslHttpSampler extends DslBaseHttpSampler<DslHttpSampler>
| Modifier and Type | Class and Description |
|---|---|
static class |
DslHttpSampler.CodeBuilder |
static class |
DslHttpSampler.HttpClientImpl
Specifies an HTTP client implementation to be used by HTTP samplers.
|
DslBaseHttpSampler.BaseHttpSamplerCodeBuilderBaseSampler.SamplerChild| Modifier and Type | Field and Description |
|---|---|
protected List<org.apache.jmeter.protocol.http.util.HTTPArgument> |
arguments |
protected Object |
body |
protected DslHttpSampler.HttpClientImpl |
clientImpl |
protected boolean |
downloadEmbeddedResources |
protected org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy |
element |
protected String |
embeddedResourcesMatchRegex |
protected String |
embeddedResourcesNotMatchRegex |
protected Charset |
encoding |
protected List<org.apache.jmeter.protocol.http.util.HTTPFileArg> |
files |
protected Boolean |
followRedirects |
protected String |
method |
protected boolean |
multiPart |
protected PropertyScriptBuilder<String> |
urlBuilder |
connectionTimeout, headers, host, path, port, protocol, proxyPassword, proxyUrl, proxyUser, RESET_CONNECTIONS_BETWEEN_ITERATIONS_PROP, responseTimeoutchildrenguiClass, name| Constructor and Description |
|---|
DslHttpSampler(String name,
Class<? extends PropertyScriptBuilder.PropertyScript<String>> urlSolverClass) |
DslHttpSampler(String name,
Function<DslJsr223PreProcessor.PreProcessorVars,String> urlSupplier) |
DslHttpSampler(String name,
String url) |
| Modifier and Type | Method and Description |
|---|---|
DslHttpSampler |
body(Class<? extends PropertyScriptBuilder.PropertyScript<String>> bodySolverClass)
Same as
body(Function) but with support for running at scale in a remote engine. |
DslHttpSampler |
body(Function<DslJsr223PreProcessor.PreProcessorVars,String> bodySupplier)
Same as
body(String) but allows using dynamically calculated HTTP request body. |
DslHttpSampler |
body(String body)
Specifies the body to be sent in the HTTP request generated by the sampler.
|
DslHttpSampler |
bodyFile(String filePath)
Specifies a file to be sent as body of the request.
|
DslHttpSampler |
bodyFilePart(String name,
String filePath,
org.apache.http.entity.ContentType contentType)
Specifies a file to be sent in a multipart form body.
|
DslHttpSampler |
bodyPart(String name,
String value,
org.apache.http.entity.ContentType contentType)
Specifies a part of a multipart form body.
|
org.apache.jorphan.collections.HashTree |
buildTreeUnder(org.apache.jorphan.collections.HashTree parent,
BuildTreeContext context)
Builds the JMeter HashTree for this TestElement under the provided tree node.
|
DslHttpSampler |
clientImpl(DslHttpSampler.HttpClientImpl clientImpl)
Allows specifying the HTTP client implementation to use for this particular sampler.
|
org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy |
configureHttpTestElement(org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy elem) |
DslHttpSampler |
downloadEmbeddedResources()
Allows enabling automatic download of HTML embedded resources (images, iframes, etc).
|
DslHttpSampler |
downloadEmbeddedResources(boolean enable)
Same as
downloadEmbeddedResources() but allowing to enable or disable the setting. |
DslHttpSampler |
downloadEmbeddedResourcesMatching(String urlRegex)
Same as
downloadEmbeddedResources() but allowing to specify which embedded resources
to actually download. |
DslHttpSampler |
downloadEmbeddedResourcesNotMatching(String urlRegex)
Same as
downloadEmbeddedResources() but allowing to ignore embedded resources with URL
matching a given regular expression. |
DslHttpSampler |
encoding(Charset encoding)
Specifies the charset to be used to encode URLs and request contents.
|
DslHttpSampler |
followRedirects(boolean followRedirects)
Allows enabling/disabling automatic request for redirects.
|
DslHttpSampler |
method(String method)
Specifies the HTTP method to be used in the HTTP request generated by the sampler.
|
DslHttpSampler |
param(String name,
String value)
Allows specifying a query parameter or url encoded form body parameter.
|
DslHttpSampler |
post(Class<? extends PropertyScriptBuilder.PropertyScript<String>> bodySolverClass,
org.apache.http.entity.ContentType contentType)
Same as
post(Function, ContentType) but with support for running at scale in a remote
engine. |
DslHttpSampler |
post(Function<DslJsr223PreProcessor.PreProcessorVars,String> bodySupplier,
org.apache.http.entity.ContentType contentType)
Same as
post(String, ContentType) but allowing to use a dynamically calculated body. |
DslHttpSampler |
post(String body,
org.apache.http.entity.ContentType contentType)
Specifies that the sampler should send an HTTP POST to defined URL.
|
DslHttpSampler |
rawParam(String name,
String value)
Same as
param(String, String) but param name and value will be sent with no additional
encoding. |
buildTestElement, connectionTimeout, contentType, header, header, header, host, port, protocol, proxy, proxy, responseTimeoutchildrenbuildConfiguredTestElement, buildTestElementGui, configureTestElement, durationToSeconds, loadBeanProperties, showAndWaitFrameWith, showFrameWith, showInGui, showTestElementGuiclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitshowInGuiprotected final PropertyScriptBuilder<String> urlBuilder
protected String method
protected final List<org.apache.jmeter.protocol.http.util.HTTPArgument> arguments
protected Object body
protected boolean multiPart
protected final List<org.apache.jmeter.protocol.http.util.HTTPFileArg> files
protected Charset encoding
protected Boolean followRedirects
protected boolean downloadEmbeddedResources
protected String embeddedResourcesMatchRegex
protected String embeddedResourcesNotMatchRegex
protected DslHttpSampler.HttpClientImpl clientImpl
protected org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy element
public DslHttpSampler(String name, Function<DslJsr223PreProcessor.PreProcessorVars,String> urlSupplier)
public DslHttpSampler(String name, Class<? extends PropertyScriptBuilder.PropertyScript<String>> urlSolverClass)
public DslHttpSampler post(String body, org.apache.http.entity.ContentType contentType)
body - to include in HTTP POST request body.contentType - to be sent as Content-Type header in HTTP POST request.public DslHttpSampler post(Function<DslJsr223PreProcessor.PreProcessorVars,String> bodySupplier, org.apache.http.entity.ContentType contentType)
post(String, ContentType) but allowing to use a dynamically calculated body.
This method is just an abstraction that uses jexl2 function as HTTP request body.
WARNING: This only works when using embedded jmeter engine. Check the user guide for details on some alternative.
bodySupplier - function to calculate the body on each request.contentType - to be sent as Content-Type header in HTTP POST request.body(Function)public DslHttpSampler post(Class<? extends PropertyScriptBuilder.PropertyScript<String>> bodySolverClass, org.apache.http.entity.ContentType contentType)
post(Function, ContentType) 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.
post(Function, ContentType)public DslHttpSampler method(String method)
method - is the HTTP method to be used by the sampler.public DslHttpSampler body(String body)
body - to be used as in the body of the HTTP request.public DslHttpSampler body(Function<DslJsr223PreProcessor.PreProcessorVars,String> bodySupplier)
body(String) but allows using dynamically calculated HTTP request body.
This method is just an abstraction that uses jexl2 function as HTTP request body.
WARNING: This only works when using embedded jmeter engine. Check the user guide for details on some alternative.
bodySupplier - function to calculate the body on each request.public DslHttpSampler body(Class<? extends PropertyScriptBuilder.PropertyScript<String>> bodySolverClass)
body(Function) 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.
body(Function)public DslHttpSampler bodyFile(String filePath)
This method is useful to send binary data in request (eg: uploading an image to a server).
filePath - is path to the file to be sent as request body.public DslHttpSampler param(String name, String value)
JMeter will automatically URL encode provided parameters names and values. Use
rawParam(String, String) to send parameters values which are already encoded and
should be sent as is by JMeter.
JMeter will use provided parameter in query string if method is GET, DELETE or OPTIONS, otherwise it will use them in url encoded form body.
If you set a parameter with empty string name, it results in same behavior as using
body(String) method. In general, you either use body function or parameters functions,
but don't use both of them in same sampler.
name - specifies the name of the parameter.value - specifies the value of the parameter to be URL encoded to include in URLpublic DslHttpSampler rawParam(String name, String value)
param(String, String) but param name and value will be sent with no additional
encoding.param(String, String)public DslHttpSampler bodyPart(String name, String value, org.apache.http.entity.ContentType contentType)
In general, samplers should not use this method in combination with
param(String, String) or rawParam(String, String).
name - specifies the name of the part.value - specifies the string to be sent in the part.contentType - specifies the content-type associated to the part.public DslHttpSampler bodyFilePart(String name, String filePath, org.apache.http.entity.ContentType contentType)
name - is the name to be assigned to the file part.filePath - is path to the file to be sent in the multipart form body.contentType - the content type associated to the part.public DslHttpSampler encoding(Charset encoding)
encoding - contains the charset to be used.public DslHttpSampler followRedirects(boolean followRedirects)
When a response is a redirection response (3xx status code with a Location header), JMeter automatically generates a new request to the redirected destination registering the redirect request as a sub sample. This method allows enabling/disabling such behavior.
followRedirects - sets either to enable or disable automatic redirects. By default,
redirects are automatically followed.public DslHttpSampler downloadEmbeddedResources()
When enabled JMeter will automatically parse HTMLs and download any found embedded resources adding their information as sub samples of the original request.
Additionally, and in contrast to JMeter, this will download embedded resources in parallel by default (with up to 6 parallel downloads). The DSL enables this behavior by default since it is the most common way to use it to properly emulate browsers behavior.
Check JMeter HTTP Request documentation for additional details on embedded resources download.
public DslHttpSampler downloadEmbeddedResources(boolean enable)
downloadEmbeddedResources() but allowing to enable or disable the setting.
This is helpful when the resolution is taken at runtime.
enable - specifies to enable or disable the setting. By default, it is set to false.public DslHttpSampler downloadEmbeddedResourcesMatching(String urlRegex)
downloadEmbeddedResources() but allowing to specify which embedded resources
to actually download.
This is helpful when only some particular requests need to be downloaded and the rest should be ignored. Eg: to only make requests to the site under test, and no other external services.
An alternative is using downloadEmbeddedResourcesNotMatching(String). If a resources
matches this regex and also one specified in
downloadEmbeddedResourcesNotMatching(String), then it will be ignored.
urlRegex - specifies the regular expression which will be used to ignore embedded
resources that have a URL matching with it.downloadEmbeddedResources(),
downloadEmbeddedResourcesNotMatching(String)public DslHttpSampler downloadEmbeddedResourcesNotMatching(String urlRegex)
downloadEmbeddedResources() but allowing to ignore embedded resources with URL
matching a given regular expression.
This is helpful when some particular requests (for example to other external services) don't want to be included in the test execution.
An alternative is using downloadEmbeddedResourcesMatching(String). If a resources
matches this regex and also one specified in
downloadEmbeddedResourcesMatching(String), then it will be ignored.
urlRegex - specifies the regular expression which will be used to ignore embedded
resources that have a URL matching with it.downloadEmbeddedResources(),
downloadEmbeddedResourcesMatching(String)public DslHttpSampler clientImpl(DslHttpSampler.HttpClientImpl clientImpl)
Changing the default implementation (DslHttpSampler.HttpClientImpl.HTTP_CLIENT) to
DslHttpSampler.HttpClientImpl.JAVA may improve performance in some scenarios
(connection time, memory, cpu usage). But, Java implementation has its own limitations, check
JMeter
documentation for more details.
clientImpl - the HTTP client implementation to use. If none is specified, then
DslHttpSampler.HttpClientImpl.HTTP_CLIENT is used.public org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy configureHttpTestElement(org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy elem)
configureHttpTestElement in class DslBaseHttpSampler<DslHttpSampler>public org.apache.jorphan.collections.HashTree buildTreeUnder(org.apache.jorphan.collections.HashTree parent,
BuildTreeContext context)
DslTestElementbuildTreeUnder in interface DslTestElementbuildTreeUnder in class DslBaseHttpSampler<DslHttpSampler>parent - the node which will be the parent for the created tree.context - context information which contains information shared by elements while building
the test plan tree (eg: adding additional items to test plan when a particular protocol element
is added).Copyright © 2024. All rights reserved.