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 enumHTTPSamplerBase.SourceType
-
Field Summary
Fields Modifier and Type Field Description public final static StringARGUMENTSpublic final static StringAUTH_MANAGERpublic final static StringCOOKIE_MANAGERpublic final static StringKEYSTORE_CONFIGpublic final static StringSAMPLE_TIMEOUTpublic final static StringCACHE_MANAGERpublic final static StringHEADER_MANAGERpublic final static StringDNS_CACHE_MANAGERpublic final static StringDOMAINpublic final static StringPORTpublic final static StringPROXYSCHEMEpublic final static StringPROXYHOSTpublic final static StringPROXYPORTpublic final static StringPROXYUSERpublic final static StringPROXYPASSpublic final static StringCONNECT_TIMEOUTpublic final static StringRESPONSE_TIMEOUTpublic final static StringMETHODpublic final static StringCONTENT_ENCODINGpublic final static StringIMPLEMENTATIONpublic final static StringPATHpublic final static StringFOLLOW_REDIRECTSpublic final static StringAUTO_REDIRECTSpublic final static StringPROTOCOLpublic final static StringURLpublic final static StringIP_SOURCEpublic final static StringIP_SOURCE_TYPEpublic final static StringUSE_KEEPALIVEpublic final static StringDO_MULTIPART_POSTpublic final static StringBROWSER_COMPATIBLE_MULTIPARTpublic final static StringCONCURRENT_DWNpublic final static StringCONCURRENT_POOLpublic final static intCONCURRENT_POOL_SIZEpublic final static booleanBROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULTpublic final static intSOURCE_TYPE_DEFAULTpublic final static StringDEFAULT_METHODpublic final static StringCONTENT_TYPEpublic final static StringIMAGE_PARSERpublic final static StringEMBEDDED_URL_REpublic final static StringEMBEDDED_URL_EXCLUDE_REpublic final static StringMONITORpublic final static StringMD5public final static intUNSPECIFIED_PORTpublic final static StringUNSPECIFIED_PORT_AS_STRINGpublic final static intURL_UNSPECIFIED_PORTpublic final static StringURL_UNSPECIFIED_PORT_AS_STRINGpublic final static StringPOST_BODY_RAWpublic final static booleanPOST_BODY_RAW_DEFAULTpublic final static StringSC_MOVED_PERMANENTLYpublic final static StringSC_MOVED_TEMPORARILYpublic final static StringSC_SEE_OTHERpublic final static StringSC_TEMPORARY_REDIRECTpublic final static StringSC_PERMANENT_REDIRECTpublic final static intDEFAULT_HTTPS_PORTpublic final static StringDEFAULT_HTTPS_PORT_STRINGpublic final static intDEFAULT_HTTP_PORTpublic final static StringDEFAULT_HTTP_PORT_STRINGpublic final static StringPROTOCOL_HTTPpublic final static StringPROTOCOL_HTTPSpublic final static StringHEADpublic final static StringPOSTpublic final static StringPUTpublic final static StringGETpublic final static StringOPTIONSpublic final static StringTRACEpublic final static StringDELETEpublic final static StringPATCHpublic final static StringPROPFINDpublic final static StringPROPPATCHpublic final static StringMKCOLpublic final static StringCOPYpublic final static StringMOVEpublic final static StringLOCKpublic final static StringUNLOCKpublic final static StringCONNECTpublic final static StringREPORTpublic final static StringMKCALENDARpublic final static StringSEARCHpublic final static StringHEADER_AUTHORIZATIONpublic final static StringHEADER_COOKIEpublic final static StringHEADER_COOKIE_IN_REQUESTpublic final static StringHEADER_CONNECTIONpublic final static StringCONNECTION_CLOSEpublic final static StringKEEP_ALIVEpublic final static StringTRANSFER_ENCODINGpublic final static StringHEADER_CONTENT_ENCODINGpublic final static StringHTTP_1_1public final static StringHEADER_SET_COOKIEpublic final static StringENCODING_BROTLIpublic final static StringENCODING_DEFLATEpublic final static StringENCODING_GZIPpublic final static StringHEADER_CONTENT_DISPOSITIONpublic final static StringHEADER_CONTENT_TYPEpublic final static StringHEADER_CONTENT_LENGTHpublic final static StringHEADER_HOSTpublic final static StringHEADER_LOCAL_ADDRESSpublic final static StringHEADER_LOCATIONpublic final static StringAPPLICATION_X_WWW_FORM_URLENCODEDpublic final static StringMULTIPART_FORM_DATApublic final static StringIF_NONE_MATCHpublic final static StringIF_MODIFIED_SINCEpublic final static StringETAGpublic final static StringLAST_MODIFIEDpublic final static StringEXPIRESpublic final static StringCACHE_CONTROLpublic final static StringDATEpublic final static StringVARYpublic transient JMeterContextthreadContextpublic transient StringthreadNamepublic final static TestElement.CompanionCompanionpublic final static StringNAMEpublic final static StringGUI_CLASSpublic final static StringENABLEDpublic final static StringTEST_CLASSpublic final static StringCOMMENTS
-
Method Summary
Modifier and Type Method Description HTTPSamplerBaseSchemagetSchema()PropertiesAccessor<out HTTPSamplerBase, out HTTPSamplerBaseSchema>getProps()static Array<String>getSourceTypeList()booleangetSendFileAsPostBody()Determine if the file should be sent as the entire Content body, i.e. booleangetSendParameterValuesAsPostBody()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 booleangetUseMultipartForPost()Determine if we should use multipart/form-data or application/x-www-form-urlencoded for the post booleangetUseMultipart()Determine if we should use multipart/form-data or application/x-www-form-urlencoded for the post voidsetProtocol(String value)StringgetProtocol()Gets the protocol, with default. voidsetPath(String path)Sets the Path attribute of the UrlConfig object Also calls parseArguments to extract and store any query arguments voidsetPath(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. StringgetPath()voidsetFollowRedirects(boolean value)booleangetFollowRedirects()voidsetAutoRedirects(boolean value)booleangetAutoRedirects()voidsetMethod(String value)StringgetMethod()voidsetContentEncoding(String charsetName)Sets the value of the encoding to be used for the content. StringgetContentEncoding()voidsetUseKeepAlive(boolean value)booleangetUseKeepAlive()voidsetDoMultipartPost(boolean value)booleangetDoMultipartPost()voidsetDoMultipart(boolean value)booleangetDoMultipart()voidsetDoBrowserCompatibleMultipart(boolean value)booleangetDoBrowserCompatibleMultipart()voidsetMonitor(String value)voidsetMonitor(boolean truth)StringgetMonitor()booleanisMonitor()voidsetImplementation(String value)StringgetImplementation()booleanuseMD5()voidsetMD5(boolean value)voidaddEncodedArgument(String name, String value)Add an argument which has already been encoded voidaddEncodedArgument(String name, String value, String metaData, String contentEncoding)Creates an HTTPArgument and adds it to the current set getArguments of arguments. voidaddEncodedArgument(String name, String value, String metaData)voidaddNonEncodedArgument(String name, String value, String metadata)voidaddNonEncodedArgument(String name, String value, String metadata, String contentType)voidaddArgument(String name, String value)voidaddArgument(String name, String value, String metadata)booleanhasArguments()voidaddTestElement(TestElement el)voidclearTestElementChildren()Clears the Header Manager property so subsequent loops don't keep merging more elements voidsetPort(int value)static intgetDefaultPort(String protocol, int port)Get the port number for a URL, applying defaults if necessary. intgetPortIfSpecified()Get the port number from the port string, allowing for trailing blanks. booleanisProtocolDefaultPort()Tell whether the default port for the specified protocol is used intgetPort()Get the port; apply the default for the protocol if necessary. voidsetDomain(String value)StringgetDomain()voidsetConnectTimeout(String value)intgetConnectTimeout()voidsetResponseTimeout(String value)intgetResponseTimeout()StringgetProxyScheme()voidsetProxyScheme(String schema)StringgetProxyHost()voidsetProxyHost(String host)intgetProxyPortInt()voidsetProxyPortInt(String port)StringgetProxyUser()voidsetProxyUser(String user)StringgetProxyPass()voidsetProxyPass(String pass)final voidsetArguments(Arguments value)ArgumentsgetArguments()voidsetPostBodyRaw(boolean value)booleangetPostBodyRaw()voidsetAuthManager(AuthManager value)AuthManagergetAuthManager()voidsetHeaderManager(HeaderManager value)HeaderManagergetHeaderManager()voidsetCookieManager(CookieManager value)CookieManagergetCookieManager()voidsetKeystoreConfig(KeystoreConfig value)KeystoreConfiggetKeystoreConfig()voidsetCacheManager(CacheManager value)CacheManagergetCacheManager()DNSCacheManagergetDNSResolver()voidsetDNSResolver(DNSCacheManager cacheManager)booleanisImageParser()voidsetImageParser(boolean parseImages)StringgetEmbeddedUrlRE()Get the regular expression URLs must match. voidsetEmbeddedUrlRE(String regex)StringgetEmbededUrlExcludeRE()voidsetEmbeddedUrlExcludeRE(String regex)URLgetUrl()Get the URL, built from its component parts. StringgetQueryString()Gets the QueryString attribute of the UrlConfig object, using UTF-8 to encode the URL StringgetQueryString(String contentEncoding)Gets the QueryString attribute of the UrlConfig object, using the specified encoding to encode the parameter values put into the URL voidparseArguments(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. voidparseArguments(String queryString)StringtoString()SampleResultsample(Entry e)Do a sampling and return its results. SampleResultsample()Perform a sample, and return the results voidtestEnded()voidtestEnded(String host)voidtestStarted()voidtestStarted(String host)Array<HTTPFileArg>getHTTPFiles()Get the collection of files as a list. intgetHTTPFileCount()voidsetHTTPFiles(Array<HTTPFileArg> files)Saves the list of files. static Array<String>getValidMethodsAsArray()static booleanisSecure(String protocol)static booleanisSecure(URL url)voidthreadStarted()voidthreadFinished()voidtestIterationStart(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. voidsetIpSource(String value)set IP source to use - does not apply to Java HTTP implementation currently StringgetIpSource()get IP source to use - does not apply to Java HTTP implementation currently voidsetIpSourceType(int value)set IP/address source type to use intgetIpSourceType()get IP/address source type to use booleanisConcurrentDwn()Return if used a concurrent thread pool to get embedded resources. voidsetConcurrentDwn(boolean concurrentDwn)StringgetConcurrentPool()Get the pool size for concurrent thread pool to get embedded resources. voidsetConcurrentPool(String poolSize)booleanapplies(ConfigTestElement configElement)intreplace(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-Entryto 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)
-
-
-
-