Class HTTPSamplerBase
-
- All Implemented Interfaces:
-
java.io.Serializable
,java.lang.Cloneable
,org.apache.jmeter.engine.util.ConfigMergabilityIndicator
,org.apache.jmeter.gui.Replaceable
,org.apache.jmeter.gui.Searchable
,org.apache.jmeter.protocol.http.util.HTTPConstantsInterface
,org.apache.jmeter.samplers.Sampler
,org.apache.jmeter.testelement.TestElement
,org.apache.jmeter.testelement.TestIterationListener
,org.apache.jmeter.testelement.TestStateListener
,org.apache.jmeter.testelement.ThreadListener
public abstract class HTTPSamplerBase extends AbstractSampler implements TestStateListener, TestIterationListener, ThreadListener, HTTPConstantsInterface, Replaceable
Common constants and methods for HTTP samplers
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enum
HTTPSamplerBase.SourceType
-
Field Summary
Fields Modifier and Type Field Description public final static String
ARGUMENTS
public final static String
AUTH_MANAGER
public final static String
COOKIE_MANAGER
public final static String
KEYSTORE_CONFIG
public final static String
SAMPLE_TIMEOUT
public final static String
CACHE_MANAGER
public final static String
HEADER_MANAGER
public final static String
DNS_CACHE_MANAGER
public final static String
DOMAIN
public final static String
PORT
public final static String
PROXYSCHEME
public final static String
PROXYHOST
public final static String
PROXYPORT
public final static String
PROXYUSER
public final static String
PROXYPASS
public final static String
CONNECT_TIMEOUT
public final static String
RESPONSE_TIMEOUT
public final static String
METHOD
public final static String
CONTENT_ENCODING
public final static String
IMPLEMENTATION
public final static String
PATH
public final static String
FOLLOW_REDIRECTS
public final static String
AUTO_REDIRECTS
public final static String
PROTOCOL
public final static String
URL
public final static String
IP_SOURCE
public final static String
IP_SOURCE_TYPE
public final static String
USE_KEEPALIVE
public final static String
DO_MULTIPART_POST
public final static String
BROWSER_COMPATIBLE_MULTIPART
public final static String
CONCURRENT_DWN
public final static String
CONCURRENT_POOL
public final static int
CONCURRENT_POOL_SIZE
public final static boolean
BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT
public final static int
SOURCE_TYPE_DEFAULT
public final static String
DEFAULT_METHOD
public final static String
CONTENT_TYPE
public final static String
IMAGE_PARSER
public final static String
EMBEDDED_URL_RE
public final static String
EMBEDDED_URL_EXCLUDE_RE
public final static String
MONITOR
public final static String
MD5
public final static int
UNSPECIFIED_PORT
public final static String
UNSPECIFIED_PORT_AS_STRING
public final static int
URL_UNSPECIFIED_PORT
public final static String
URL_UNSPECIFIED_PORT_AS_STRING
public final static String
POST_BODY_RAW
public final static boolean
POST_BODY_RAW_DEFAULT
public final static String
SC_MOVED_PERMANENTLY
public final static String
SC_MOVED_TEMPORARILY
public final static String
SC_SEE_OTHER
public final static String
SC_TEMPORARY_REDIRECT
public final static String
SC_PERMANENT_REDIRECT
public final static int
DEFAULT_HTTPS_PORT
public final static String
DEFAULT_HTTPS_PORT_STRING
public final static int
DEFAULT_HTTP_PORT
public final static String
DEFAULT_HTTP_PORT_STRING
public final static String
PROTOCOL_HTTP
public final static String
PROTOCOL_HTTPS
public final static String
HEAD
public final static String
POST
public final static String
PUT
public final static String
GET
public final static String
OPTIONS
public final static String
TRACE
public final static String
DELETE
public final static String
PATCH
public final static String
PROPFIND
public final static String
PROPPATCH
public final static String
MKCOL
public final static String
COPY
public final static String
MOVE
public final static String
LOCK
public final static String
UNLOCK
public final static String
CONNECT
public final static String
REPORT
public final static String
MKCALENDAR
public final static String
SEARCH
public final static String
HEADER_AUTHORIZATION
public final static String
HEADER_COOKIE
public final static String
HEADER_COOKIE_IN_REQUEST
public final static String
HEADER_CONNECTION
public final static String
CONNECTION_CLOSE
public final static String
KEEP_ALIVE
public final static String
TRANSFER_ENCODING
public final static String
HEADER_CONTENT_ENCODING
public final static String
HTTP_1_1
public final static String
HEADER_SET_COOKIE
public final static String
ENCODING_BROTLI
public final static String
ENCODING_DEFLATE
public final static String
ENCODING_GZIP
public final static String
HEADER_CONTENT_DISPOSITION
public final static String
HEADER_CONTENT_TYPE
public final static String
HEADER_CONTENT_LENGTH
public final static String
HEADER_HOST
public final static String
HEADER_LOCAL_ADDRESS
public final static String
HEADER_LOCATION
public final static String
APPLICATION_X_WWW_FORM_URLENCODED
public final static String
MULTIPART_FORM_DATA
public final static String
IF_NONE_MATCH
public final static String
IF_MODIFIED_SINCE
public final static String
ETAG
public final static String
LAST_MODIFIED
public final static String
EXPIRES
public final static String
CACHE_CONTROL
public final static String
DATE
public final static String
VARY
public transient JMeterContext
threadContext
public transient String
threadName
public final static TestElement.Companion
Companion
public final static String
NAME
public final static String
GUI_CLASS
public final static String
ENABLED
public final static String
TEST_CLASS
public final static String
COMMENTS
-
Method Summary
Modifier and Type Method Description HTTPSamplerBaseSchema
getSchema()
PropertiesAccessor<out HTTPSamplerBase, out HTTPSamplerBaseSchema>
getProps()
static Array<String>
getSourceTypeList()
boolean
getSendFileAsPostBody()
Determine if the file should be sent as the entire Content body, i.e. boolean
getSendParameterValuesAsPostBody()
Determine if none of the parameters have a name, and if that is the case, it means that the parameter values should be sent as the entity body boolean
getUseMultipartForPost()
Determine if we should use multipart/form-data or application/x-www-form-urlencoded for the post boolean
getUseMultipart()
Determine if we should use multipart/form-data or application/x-www-form-urlencoded for the post void
setProtocol(String value)
String
getProtocol()
Gets the protocol, with default. void
setPath(String path)
Sets the Path attribute of the UrlConfig object Also calls parseArguments to extract and store any query arguments void
setPath(String path, String contentEncoding)
Sets the PATH property; if the request is a GET or DELETE (and the path does not start with http[s]://) it also calls parseArguments to extract and store any query arguments. String
getPath()
void
setFollowRedirects(boolean value)
boolean
getFollowRedirects()
void
setAutoRedirects(boolean value)
boolean
getAutoRedirects()
void
setMethod(String value)
String
getMethod()
void
setContentEncoding(String charsetName)
Sets the value of the encoding to be used for the content. String
getContentEncoding()
void
setUseKeepAlive(boolean value)
boolean
getUseKeepAlive()
void
setDoMultipartPost(boolean value)
boolean
getDoMultipartPost()
void
setDoMultipart(boolean value)
boolean
getDoMultipart()
void
setDoBrowserCompatibleMultipart(boolean value)
boolean
getDoBrowserCompatibleMultipart()
void
setMonitor(String value)
void
setMonitor(boolean truth)
String
getMonitor()
boolean
isMonitor()
void
setImplementation(String value)
String
getImplementation()
boolean
useMD5()
void
setMD5(boolean value)
void
addEncodedArgument(String name, String value)
Add an argument which has already been encoded void
addEncodedArgument(String name, String value, String metaData, String contentEncoding)
Creates an HTTPArgument and adds it to the current set getArguments of arguments. void
addEncodedArgument(String name, String value, String metaData)
void
addNonEncodedArgument(String name, String value, String metadata)
void
addNonEncodedArgument(String name, String value, String metadata, String contentType)
void
addArgument(String name, String value)
void
addArgument(String name, String value, String metadata)
boolean
hasArguments()
void
addTestElement(TestElement el)
void
clearTestElementChildren()
Clears the Header Manager property so subsequent loops don't keep merging more elements void
setPort(int value)
static int
getDefaultPort(String protocol, int port)
Get the port number for a URL, applying defaults if necessary. int
getPortIfSpecified()
Get the port number from the port string, allowing for trailing blanks. boolean
isProtocolDefaultPort()
Tell whether the default port for the specified protocol is used int
getPort()
Get the port; apply the default for the protocol if necessary. void
setDomain(String value)
String
getDomain()
void
setConnectTimeout(String value)
int
getConnectTimeout()
void
setResponseTimeout(String value)
int
getResponseTimeout()
String
getProxyScheme()
void
setProxyScheme(String schema)
String
getProxyHost()
void
setProxyHost(String host)
int
getProxyPortInt()
void
setProxyPortInt(String port)
String
getProxyUser()
void
setProxyUser(String user)
String
getProxyPass()
void
setProxyPass(String pass)
final void
setArguments(Arguments value)
Arguments
getArguments()
void
setPostBodyRaw(boolean value)
boolean
getPostBodyRaw()
void
setAuthManager(AuthManager value)
AuthManager
getAuthManager()
void
setHeaderManager(HeaderManager value)
HeaderManager
getHeaderManager()
void
setCookieManager(CookieManager value)
CookieManager
getCookieManager()
void
setKeystoreConfig(KeystoreConfig value)
KeystoreConfig
getKeystoreConfig()
void
setCacheManager(CacheManager value)
CacheManager
getCacheManager()
DNSCacheManager
getDNSResolver()
void
setDNSResolver(DNSCacheManager cacheManager)
boolean
isImageParser()
void
setImageParser(boolean parseImages)
String
getEmbeddedUrlRE()
Get the regular expression URLs must match. void
setEmbeddedUrlRE(String regex)
String
getEmbededUrlExcludeRE()
void
setEmbeddedUrlExcludeRE(String regex)
URL
getUrl()
Get the URL, built from its component parts. String
getQueryString()
Gets the QueryString attribute of the UrlConfig object, using UTF-8 to encode the URL String
getQueryString(String contentEncoding)
Gets the QueryString attribute of the UrlConfig object, using the specified encoding to encode the parameter values put into the URL void
parseArguments(String queryString, String contentEncoding)
This method allows a proxy server to send over the raw text from a browser's output stream to be parsed and stored correctly into the UrlConfig object. void
parseArguments(String queryString)
String
toString()
SampleResult
sample(Entry e)
Do a sampling and return its results. SampleResult
sample()
Perform a sample, and return the results void
testEnded()
void
testEnded(String host)
void
testStarted()
void
testStarted(String host)
Array<HTTPFileArg>
getHTTPFiles()
Get the collection of files as a list. int
getHTTPFileCount()
void
setHTTPFiles(Array<HTTPFileArg> files)
Saves the list of files. static Array<String>
getValidMethodsAsArray()
static boolean
isSecure(String protocol)
static boolean
isSecure(URL url)
void
threadStarted()
void
threadFinished()
void
testIterationStart(LoopIterationEvent event)
Array<byte>
readResponse(SampleResult sampleResult, InputStream in, long length)
Read response from the input stream, converting to MD5 digest if the useMD5 property is set. void
setIpSource(String value)
set IP source to use - does not apply to Java HTTP implementation currently String
getIpSource()
get IP source to use - does not apply to Java HTTP implementation currently void
setIpSourceType(int value)
set IP/address source type to use int
getIpSourceType()
get IP/address source type to use boolean
isConcurrentDwn()
Return if used a concurrent thread pool to get embedded resources. void
setConcurrentDwn(boolean concurrentDwn)
String
getConcurrentPool()
Get the pool size for concurrent thread pool to get embedded resources. void
setConcurrentPool(String poolSize)
boolean
applies(ConfigTestElement configElement)
int
replace(String regex, String replaceBy, boolean caseSensitive)
Replace by replaceBy in path and body (arguments) properties -
Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement
canRemove, clear, clone, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getPropertyOrNull, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse
-
Methods inherited from class org.apache.jmeter.testelement.TestElement
get, get, get, get, get, get, get, get, get, getOrCreate, getOrCreate, getOrNull, getOrNull, getOrNull, getString, removed, set
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getSchema
HTTPSamplerBaseSchema getSchema()
-
getProps
PropertiesAccessor<out HTTPSamplerBase, out HTTPSamplerBaseSchema> getProps()
-
getSourceTypeList
static Array<String> getSourceTypeList()
-
getSendFileAsPostBody
boolean getSendFileAsPostBody()
Determine if the file should be sent as the entire Content body, i.e. without any additional wrapping.
-
getSendParameterValuesAsPostBody
boolean getSendParameterValuesAsPostBody()
Determine if none of the parameters have a name, and if that is the case, it means that the parameter values should be sent as the entity body
-
getUseMultipartForPost
boolean getUseMultipartForPost()
Determine if we should use multipart/form-data or application/x-www-form-urlencoded for the post
-
getUseMultipart
boolean getUseMultipart()
Determine if we should use multipart/form-data or application/x-www-form-urlencoded for the post
-
setProtocol
void setProtocol(String value)
-
getProtocol
String getProtocol()
Gets the protocol, with default.
-
setPath
void setPath(String path)
Sets the Path attribute of the UrlConfig object Also calls parseArguments to extract and store any query arguments
- Parameters:
path
- The new Path value
-
setPath
void setPath(String path, String contentEncoding)
Sets the PATH property; if the request is a GET or DELETE (and the path does not start with http[s]://) it also calls parseArguments to extract and store any query arguments.
- Parameters:
path
- The new Path valuecontentEncoding
- The encoding used for the querystring parameter values
-
setFollowRedirects
void setFollowRedirects(boolean value)
-
getFollowRedirects
boolean getFollowRedirects()
-
setAutoRedirects
void setAutoRedirects(boolean value)
-
getAutoRedirects
boolean getAutoRedirects()
-
setContentEncoding
void setContentEncoding(String charsetName)
Sets the value of the encoding to be used for the content.
- Parameters:
charsetName
- the name of the encoding to be used
-
getContentEncoding
String getContentEncoding()
-
setUseKeepAlive
void setUseKeepAlive(boolean value)
-
getUseKeepAlive
boolean getUseKeepAlive()
-
setDoMultipartPost
@Deprecated() void setDoMultipartPost(boolean value)
- Parameters:
value
- flag whether multiparts should be used
-
getDoMultipartPost
@Deprecated() boolean getDoMultipartPost()
-
setDoMultipart
void setDoMultipart(boolean value)
-
getDoMultipart
boolean getDoMultipart()
-
setDoBrowserCompatibleMultipart
void setDoBrowserCompatibleMultipart(boolean value)
-
getDoBrowserCompatibleMultipart
boolean getDoBrowserCompatibleMultipart()
-
setMonitor
void setMonitor(String value)
-
setMonitor
void setMonitor(boolean truth)
-
getMonitor
@Deprecated() String getMonitor()
-
isMonitor
@Deprecated() boolean isMonitor()
-
setImplementation
void setImplementation(String value)
-
getImplementation
String getImplementation()
-
useMD5
boolean useMD5()
-
setMD5
void setMD5(boolean value)
-
addEncodedArgument
void addEncodedArgument(String name, String value)
Add an argument which has already been encoded
- Parameters:
name
- name of the argumentvalue
- value of the argument
-
addEncodedArgument
void addEncodedArgument(String name, String value, String metaData, String contentEncoding)
Creates an HTTPArgument and adds it to the current set getArguments of arguments.
- Parameters:
name
- - the parameter namevalue
- - the parameter valuemetaData
- - normally just '='contentEncoding
- - the encoding, may be null
-
addEncodedArgument
void addEncodedArgument(String name, String value, String metaData)
-
addNonEncodedArgument
void addNonEncodedArgument(String name, String value, String metadata)
-
addNonEncodedArgument
void addNonEncodedArgument(String name, String value, String metadata, String contentType)
-
addArgument
void addArgument(String name, String value)
-
addArgument
void addArgument(String name, String value, String metadata)
-
hasArguments
boolean hasArguments()
-
addTestElement
void addTestElement(TestElement el)
-
clearTestElementChildren
void clearTestElementChildren()
Clears the Header Manager property so subsequent loops don't keep merging more elements
-
setPort
void setPort(int value)
-
getDefaultPort
static int getDefaultPort(String protocol, int port)
Get the port number for a URL, applying defaults if necessary. (Called by CookieManager.)
- Parameters:
protocol
- from getProtocolport
- number from getPort
-
getPortIfSpecified
int getPortIfSpecified()
Get the port number from the port string, allowing for trailing blanks.
-
isProtocolDefaultPort
boolean isProtocolDefaultPort()
Tell whether the default port for the specified protocol is used
-
getPort
int getPort()
Get the port; apply the default for the protocol if necessary.
-
setConnectTimeout
void setConnectTimeout(String value)
-
getConnectTimeout
int getConnectTimeout()
-
setResponseTimeout
void setResponseTimeout(String value)
-
getResponseTimeout
int getResponseTimeout()
-
getProxyScheme
String getProxyScheme()
-
setProxyScheme
void setProxyScheme(String schema)
-
getProxyHost
String getProxyHost()
-
setProxyHost
void setProxyHost(String host)
-
getProxyPortInt
int getProxyPortInt()
-
setProxyPortInt
void setProxyPortInt(String port)
-
getProxyUser
String getProxyUser()
-
setProxyUser
void setProxyUser(String user)
-
getProxyPass
String getProxyPass()
-
setProxyPass
void setProxyPass(String pass)
-
setArguments
final void setArguments(Arguments value)
-
getArguments
Arguments getArguments()
-
setPostBodyRaw
void setPostBodyRaw(boolean value)
- Parameters:
value
- Boolean that indicates body will be sent as is
-
getPostBodyRaw
boolean getPostBodyRaw()
-
setAuthManager
void setAuthManager(AuthManager value)
-
getAuthManager
AuthManager getAuthManager()
-
setHeaderManager
void setHeaderManager(HeaderManager value)
-
getHeaderManager
HeaderManager getHeaderManager()
-
setCookieManager
void setCookieManager(CookieManager value)
-
getCookieManager
CookieManager getCookieManager()
-
setKeystoreConfig
void setKeystoreConfig(KeystoreConfig value)
-
getKeystoreConfig
KeystoreConfig getKeystoreConfig()
-
setCacheManager
void setCacheManager(CacheManager value)
-
getCacheManager
CacheManager getCacheManager()
-
getDNSResolver
DNSCacheManager getDNSResolver()
-
setDNSResolver
void setDNSResolver(DNSCacheManager cacheManager)
-
isImageParser
boolean isImageParser()
-
setImageParser
void setImageParser(boolean parseImages)
-
getEmbeddedUrlRE
String getEmbeddedUrlRE()
Get the regular expression URLs must match.
-
setEmbeddedUrlRE
void setEmbeddedUrlRE(String regex)
-
getEmbededUrlExcludeRE
String getEmbededUrlExcludeRE()
-
setEmbeddedUrlExcludeRE
void setEmbeddedUrlExcludeRE(String regex)
-
getUrl
URL getUrl()
Get the URL, built from its component parts.
As a special case, if the path starts with "http[s]://", then the path is assumed to be the entire URL.
-
getQueryString
String getQueryString()
Gets the QueryString attribute of the UrlConfig object, using UTF-8 to encode the URL
-
getQueryString
String getQueryString(String contentEncoding)
Gets the QueryString attribute of the UrlConfig object, using the specified encoding to encode the parameter values put into the URL
- Parameters:
contentEncoding
- the encoding to use for encoding parameter values
-
parseArguments
void parseArguments(String queryString, String contentEncoding)
This method allows a proxy server to send over the raw text from a browser's output stream to be parsed and stored correctly into the UrlConfig object. For each name found, addArgument() is called
- Parameters:
queryString
- - the query string, might be the post body of a http post request.contentEncoding
- - the content encoding of the query string; if non-null then it is used to decode the
-
parseArguments
void parseArguments(String queryString)
-
sample
SampleResult sample(Entry e)
Do a sampling and return its results.
- Parameters:
e
-Entry
to be sampled
-
sample
SampleResult sample()
Perform a sample, and return the results
-
testEnded
void testEnded()
-
testStarted
void testStarted()
-
testStarted
void testStarted(String host)
-
getHTTPFiles
Array<HTTPFileArg> getHTTPFiles()
Get the collection of files as a list. The list is built up from the filename/filefield/mimetype properties, plus any additional entries saved in the FILE_ARGS property. If there are no valid file entries, then an empty list is returned.
-
getHTTPFileCount
int getHTTPFileCount()
-
setHTTPFiles
void setHTTPFiles(Array<HTTPFileArg> files)
Saves the list of files. The first file is saved in the Filename/field/mimetype properties. Any additional files are saved in the FILE_ARGS array.
- Parameters:
files
- list of files to save
-
getValidMethodsAsArray
static Array<String> getValidMethodsAsArray()
-
threadStarted
void threadStarted()
-
threadFinished
void threadFinished()
-
testIterationStart
void testIterationStart(LoopIterationEvent event)
-
readResponse
Array<byte> readResponse(SampleResult sampleResult, InputStream in, long length)
Read response from the input stream, converting to MD5 digest if the useMD5 property is set.
For the MD5 case, the result byte count is set to the size of the original response.
Closes the inputStream
- Parameters:
sampleResult
- sample to store information about the response intoin
- input stream from which to read the responselength
- expected input length or zero
-
setIpSource
void setIpSource(String value)
set IP source to use - does not apply to Java HTTP implementation currently
- Parameters:
value
- IP source to use
-
getIpSource
String getIpSource()
get IP source to use - does not apply to Java HTTP implementation currently
-
setIpSourceType
void setIpSourceType(int value)
set IP/address source type to use
- Parameters:
value
- type of the IP/address source
-
getIpSourceType
int getIpSourceType()
get IP/address source type to use
-
isConcurrentDwn
boolean isConcurrentDwn()
Return if used a concurrent thread pool to get embedded resources.
-
setConcurrentDwn
void setConcurrentDwn(boolean concurrentDwn)
-
getConcurrentPool
String getConcurrentPool()
Get the pool size for concurrent thread pool to get embedded resources.
-
setConcurrentPool
void setConcurrentPool(String poolSize)
-
applies
boolean applies(ConfigTestElement configElement)
-
-
-
-