|
Apache JMeter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jmeter.testelement.AbstractTestElement
org.apache.jmeter.samplers.AbstractSampler
org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase
public abstract class HTTPSamplerBase
Common constants and methods for HTTP samplers
Field Summary | |
---|---|
static java.lang.String |
ARGUMENTS
|
static java.lang.String |
AUTH_MANAGER
|
static java.lang.String |
AUTO_REDIRECTS
|
static java.lang.String |
CACHE_MANAGER
|
static java.lang.String |
CLIENT
|
static java.lang.String |
CONNECT_TIMEOUT
|
static java.lang.String |
CONTENT_ENCODING
|
static java.lang.String |
CONTENT_TYPE
|
static java.lang.String |
COOKIE_MANAGER
|
static java.lang.String |
DEFAULT_METHOD
|
static java.lang.String |
DO_MULTIPART_POST
|
static java.lang.String |
DOMAIN
|
static java.lang.String |
EMBEDDED_URL_RE
|
static java.lang.String |
FOLLOW_REDIRECTS
|
static java.lang.String |
HEADER_MANAGER
|
static java.lang.String |
IMAGE_PARSER
|
static java.lang.String |
IMPLEMENTATION
|
protected static int |
MAX_FRAME_DEPTH
|
protected static int |
MAX_REDIRECTS
|
static java.lang.String |
METHOD
|
static java.lang.String |
MONITOR
|
protected static java.lang.String |
NON_HTTP_RESPONSE_CODE
|
protected static java.lang.String |
NON_HTTP_RESPONSE_MESSAGE
|
static java.lang.String |
PATH
|
static java.lang.String |
PORT
|
static java.lang.String |
PROTOCOL
|
static java.lang.String |
RESPONSE_TIMEOUT
|
static int |
UNSPECIFIED_PORT
A number to indicate that the port has not been set. |
static java.lang.String |
UNSPECIFIED_PORT_AS_STRING
|
static java.lang.String |
URL
|
static int |
URL_UNSPECIFIED_PORT
If the port is not present in a URL, getPort() returns -1 |
static java.lang.String |
URL_UNSPECIFIED_PORT_AS_STRING
|
static java.lang.String |
USE_KEEPALIVE
|
Fields inherited from interface org.apache.jmeter.protocol.http.util.HTTPConstantsInterface |
---|
APPLICATION_X_WWW_FORM_URLENCODED, CONNECTION_CLOSE, DEFAULT_HTTP_PORT, DEFAULT_HTTP_PORT_STRING, DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_PORT_STRING, DELETE, ENCODING_GZIP, ETAG, GET, HEAD, HEADER_AUTHORIZATION, HEADER_CONNECTION, HEADER_CONTENT_DISPOSITION, HEADER_CONTENT_ENCODING, HEADER_CONTENT_LENGTH, HEADER_CONTENT_TYPE, HEADER_COOKIE, HEADER_LOCATION, HEADER_SET_COOKIE, HTTP_1_1, IF_MODIFIED_SINCE, IF_NONE_MATCH, KEEP_ALIVE, LAST_MODIFIED, MULTIPART_FORM_DATA, OPTIONS, POST, PROTOCOL_HTTP, PROTOCOL_HTTPS, PUT, TRACE, TRANSFER_ENCODING |
Fields inherited from interface org.apache.jmeter.testelement.TestElement |
---|
COMMENTS, ENABLED, GUI_CLASS, NAME, TEST_CLASS |
Constructor Summary | |
---|---|
HTTPSamplerBase()
|
Method Summary | |
---|---|
void |
addArgument(java.lang.String name,
java.lang.String value)
|
void |
addArgument(java.lang.String name,
java.lang.String value,
java.lang.String metadata)
|
void |
addEncodedArgument(java.lang.String name,
java.lang.String value)
Add an argument which has already been encoded |
void |
addEncodedArgument(java.lang.String name,
java.lang.String value,
java.lang.String metaData)
|
void |
addEncodedArgument(java.lang.String name,
java.lang.String value,
java.lang.String metaData,
java.lang.String contentEncoding)
|
void |
addNonEncodedArgument(java.lang.String name,
java.lang.String value,
java.lang.String metadata)
|
void |
addTestElement(TestElement el)
|
java.lang.Object |
clone()
|
protected HTTPSampleResult |
downloadPageResources(HTTPSampleResult res,
HTTPSampleResult container,
int frameDepth)
Download the resources of an HTML page. |
protected static java.lang.String |
encodeBackSlashes(java.lang.String value)
|
protected java.lang.String |
encodeSpaces(java.lang.String path)
|
protected HTTPSampleResult |
errorResult(java.lang.Throwable e,
HTTPSampleResult res)
Obtain a result that will help inform the user that an error has occured during sampling, and how long it took to detect the error. |
protected HTTPSampleResult |
followRedirects(HTTPSampleResult res,
int frameDepth)
Iteratively download the redirect targets of a redirect response. |
Arguments |
getArguments()
|
AuthManager |
getAuthManager()
|
boolean |
getAutoRedirects()
|
CacheManager |
getCacheManager()
|
java.lang.String |
getClient()
|
int |
getConnectTimeout()
|
java.lang.String |
getContentEncoding()
|
CookieManager |
getCookieManager()
|
static int |
getDefaultPort(java.lang.String protocol,
int port)
Get the port number for a URL, applying defaults if necessary. |
java.lang.String |
getDomain()
|
boolean |
getDoMultipartPost()
|
java.lang.String |
getEmbeddedUrlRE()
Get the regular expression URLs must match. |
java.lang.String |
getFileField()
Deprecated. Use getHTTPFiles() array instead |
java.lang.String |
getFilename()
Deprecated. Use getHTTPFiles() array instead |
boolean |
getFollowRedirects()
|
HeaderManager |
getHeaderManager()
|
int |
getHTTPFileCount()
|
HTTPFileArg[] |
getHTTPFiles()
Get the collection of files as a list. |
java.lang.String |
getImplementation()
|
java.lang.String |
getMethod()
|
java.lang.String |
getMimetype()
Deprecated. Use getHTTPFiles() array instead |
java.lang.String |
getMonitor()
|
java.lang.String |
getPath()
|
int |
getPort()
Get the port; apply the default for the protocol if necessary. |
int |
getPortIfSpecified()
Get the port number from the port string, allowing for trailing blanks. |
java.lang.String |
getProtocol()
Gets the protocol, with default. |
java.lang.String |
getQueryString()
Gets the QueryString attribute of the UrlConfig object, using UTF-8 to encode the URL |
java.lang.String |
getQueryString(java.lang.String contentEncoding)
Gets the QueryString attribute of the UrlConfig object, using the specified encoding to encode the parameter values put into the URL |
int |
getResponseTimeout()
|
boolean |
getSendFileAsPostBody()
Determine if the file should be sent as the entire Post body, i.e. without any additional wrapping |
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 post body |
java.net.URL |
getUrl()
Get the URL, built from its component parts. |
boolean |
getUseKeepAlive()
|
boolean |
getUseMultipartForPost()
Determine if we should use multipart/form-data or application/x-www-form-urlencoded for the post |
static java.lang.String[] |
getValidMethodsAsArray()
|
boolean |
hasArguments()
|
boolean |
isImageParser()
|
boolean |
isMonitor()
|
boolean |
isProtocolDefaultPort()
Tell whether the default port for the specified protocol is used |
static boolean |
isSecure(java.lang.String protocol)
|
static boolean |
isSecure(java.net.URL url)
|
protected boolean |
isSuccessCode(int code)
Determine if the HTTP status code is successful or not i.e. in range 200 to 399 inclusive |
void |
parseArguments(java.lang.String queryString)
|
void |
parseArguments(java.lang.String queryString,
java.lang.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. |
byte[] |
readResponse(SampleResult sampleResult,
java.io.InputStream in,
int length)
Read response from the input stream, converting to MD5 digest if the useMD5 property is set. |
protected HTTPSampleResult |
resultProcessing(boolean areFollowingRedirect,
int frameDepth,
HTTPSampleResult res)
Follow redirects and download page resources if appropriate. this works, but the container stuff here is what's doing it. followRedirects() is actually doing the work to make sure we have only one container to make this work more naturally, I think this method - sample() - needs to take an HTTPSamplerResult container parameter instead of a boolean:areFollowingRedirect. |
SampleResult |
sample()
Perform a sample, and return the results |
SampleResult |
sample(Entry e)
Do a sampling and return its results. |
protected abstract HTTPSampleResult |
sample(java.net.URL u,
java.lang.String method,
boolean areFollowingRedirect,
int depth)
Samples the URL passed in and stores the result in HTTPSampleResult , following redirects and downloading
page resources as appropriate. |
void |
setArguments(Arguments value)
|
void |
setAuthManager(AuthManager value)
|
void |
setAutoRedirects(boolean value)
|
void |
setCacheManager(CacheManager value)
|
void |
setClient(java.lang.String client)
|
void |
setConnectTimeout(java.lang.String value)
|
void |
setContentEncoding(java.lang.String value)
|
void |
setCookieManager(CookieManager value)
|
void |
setDomain(java.lang.String value)
|
void |
setDoMultipartPost(boolean value)
|
void |
setEmbeddedUrlRE(java.lang.String regex)
|
void |
setFileField(java.lang.String value)
Deprecated. use setHTTPFiles() instead |
void |
setFilename(java.lang.String value)
Deprecated. use setHTTPFiles() instead |
void |
setFollowRedirects(boolean value)
|
void |
setHeaderManager(HeaderManager value)
|
void |
setHTTPFiles(HTTPFileArg[] files)
Saves the list of files. |
void |
setImageParser(boolean parseImages)
|
void |
setImplementation(java.lang.String value)
|
void |
setMD5(boolean truth)
|
void |
setMethod(java.lang.String value)
|
void |
setMimetype(java.lang.String value)
Deprecated. use setHTTPFiles() instead |
void |
setMonitor(boolean truth)
|
void |
setMonitor(java.lang.String value)
|
void |
setPath(java.lang.String path)
Sets the Path attribute of the UrlConfig object Also calls parseArguments to extract and store any query arguments |
void |
setPath(java.lang.String path,
java.lang.String contentEncoding)
Sets the Path attribute of the UrlConfig object Also calls parseArguments to extract and store any query arguments |
void |
setPort(int value)
|
void |
setProtocol(java.lang.String value)
|
void |
setResponseTimeout(java.lang.String value)
|
void |
setUseKeepAlive(boolean value)
|
void |
testEnded()
Called once for all threads after the end of a test. |
void |
testEnded(java.lang.String host)
Called once for all threads after the end of a test. |
void |
testIterationStart(LoopIterationEvent event)
Each time through a Thread Group's test script, an iteration event is fired for each thread. |
void |
testStarted()
Called just before the start of the test from the main engine thread. |
void |
testStarted(java.lang.String host)
Called just before the start of the test from the main engine thread. |
void |
threadFinished()
Called once for each thread at the end of a test |
void |
threadStarted()
Called just before the start of the thread |
java.lang.String |
toString()
|
boolean |
useMD5()
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.jmeter.testelement.TestElement |
---|
canRemove, clear, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getThreadContext, getThreadName, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, setComment, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse |
Field Detail |
---|
public static final java.lang.String ARGUMENTS
public static final java.lang.String AUTH_MANAGER
public static final java.lang.String COOKIE_MANAGER
public static final java.lang.String CACHE_MANAGER
public static final java.lang.String HEADER_MANAGER
public static final java.lang.String DOMAIN
public static final java.lang.String PORT
public static final java.lang.String CONNECT_TIMEOUT
public static final java.lang.String RESPONSE_TIMEOUT
public static final java.lang.String METHOD
public static final java.lang.String CONTENT_ENCODING
public static final java.lang.String IMPLEMENTATION
public static final java.lang.String PATH
public static final java.lang.String FOLLOW_REDIRECTS
public static final java.lang.String AUTO_REDIRECTS
public static final java.lang.String PROTOCOL
public static final java.lang.String URL
public static final java.lang.String CLIENT
public static final java.lang.String DEFAULT_METHOD
public static final java.lang.String USE_KEEPALIVE
public static final java.lang.String DO_MULTIPART_POST
public static final java.lang.String CONTENT_TYPE
public static final java.lang.String IMAGE_PARSER
public static final java.lang.String EMBEDDED_URL_RE
public static final java.lang.String MONITOR
public static final int UNSPECIFIED_PORT
public static final java.lang.String UNSPECIFIED_PORT_AS_STRING
public static final int URL_UNSPECIFIED_PORT
public static final java.lang.String URL_UNSPECIFIED_PORT_AS_STRING
protected static final java.lang.String NON_HTTP_RESPONSE_CODE
protected static final java.lang.String NON_HTTP_RESPONSE_MESSAGE
protected static final int MAX_REDIRECTS
protected static final int MAX_FRAME_DEPTH
Constructor Detail |
---|
public HTTPSamplerBase()
Method Detail |
---|
public void setFileField(java.lang.String value)
public java.lang.String getFileField()
public void setFilename(java.lang.String value)
public java.lang.String getFilename()
public void setMimetype(java.lang.String value)
value
- public java.lang.String getMimetype()
public boolean getSendFileAsPostBody()
public boolean getSendParameterValuesAsPostBody()
public boolean getUseMultipartForPost()
public void setProtocol(java.lang.String value)
public java.lang.String getProtocol()
public java.lang.String getClient()
public void setClient(java.lang.String client)
public void setPath(java.lang.String path)
path
- The new Path valuepublic void setPath(java.lang.String path, java.lang.String contentEncoding)
path
- The new Path valuecontentEncoding
- The encoding used for the querystring parameter valuespublic java.lang.String getPath()
public void setFollowRedirects(boolean value)
public boolean getFollowRedirects()
public void setAutoRedirects(boolean value)
public boolean getAutoRedirects()
public void setMethod(java.lang.String value)
public java.lang.String getMethod()
public void setContentEncoding(java.lang.String value)
public java.lang.String getContentEncoding()
public void setUseKeepAlive(boolean value)
public boolean getUseKeepAlive()
public void setDoMultipartPost(boolean value)
public boolean getDoMultipartPost()
public void setMonitor(java.lang.String value)
public void setMonitor(boolean truth)
public java.lang.String getMonitor()
public boolean isMonitor()
public void setImplementation(java.lang.String value)
public java.lang.String getImplementation()
public boolean useMD5()
public void setMD5(boolean truth)
public void addEncodedArgument(java.lang.String name, java.lang.String value)
public void addEncodedArgument(java.lang.String name, java.lang.String value, java.lang.String metaData, java.lang.String contentEncoding)
public void addEncodedArgument(java.lang.String name, java.lang.String value, java.lang.String metaData)
public void addNonEncodedArgument(java.lang.String name, java.lang.String value, java.lang.String metadata)
public void addArgument(java.lang.String name, java.lang.String value)
public void addArgument(java.lang.String name, java.lang.String value, java.lang.String metadata)
public boolean hasArguments()
public void addTestElement(TestElement el)
addTestElement
in interface TestElement
addTestElement
in class AbstractTestElement
public void setPort(int value)
public static int getDefaultPort(java.lang.String protocol, int port)
protocol
- from URL.getProtocol()
port
- number from URL.getPort()
public int getPortIfSpecified()
public boolean isProtocolDefaultPort()
public int getPort()
public void setDomain(java.lang.String value)
public java.lang.String getDomain()
public void setConnectTimeout(java.lang.String value)
public int getConnectTimeout()
public void setResponseTimeout(java.lang.String value)
public int getResponseTimeout()
public void setArguments(Arguments value)
public Arguments getArguments()
public void setAuthManager(AuthManager value)
public AuthManager getAuthManager()
public void setHeaderManager(HeaderManager value)
public HeaderManager getHeaderManager()
public void setCookieManager(CookieManager value)
public CookieManager getCookieManager()
public void setCacheManager(CacheManager value)
public CacheManager getCacheManager()
public boolean isImageParser()
public void setImageParser(boolean parseImages)
public java.lang.String getEmbeddedUrlRE()
public void setEmbeddedUrlRE(java.lang.String regex)
protected HTTPSampleResult errorResult(java.lang.Throwable e, HTTPSampleResult res)
e
- Exception representing the error.res
- SampleResult
public java.net.URL getUrl() throws java.net.MalformedURLException
As a special case, if the path starts with "http[s]://", then the path is assumed to be the entire URL.
java.net.MalformedURLException
public java.lang.String getQueryString()
public java.lang.String getQueryString(java.lang.String contentEncoding)
contentEncoding
- the encoding to use for encoding parameter values
public void parseArguments(java.lang.String queryString, java.lang.String contentEncoding)
queryString
- -
the query stringcontentEncoding
- -
the content encoding of the query string. The query string might
actually be the post body of a http post request.public void parseArguments(java.lang.String queryString)
public java.lang.String toString()
toString
in class java.lang.Object
public SampleResult sample(Entry e)
sample
in interface Sampler
e
- Entry
to be sampled
public SampleResult sample()
protected abstract HTTPSampleResult sample(java.net.URL u, java.lang.String method, boolean areFollowingRedirect, int depth)
HTTPSampleResult
, following redirects and downloading
page resources as appropriate.
When getting a redirect target, redirects are not followed and resources are not downloaded. The caller will take care of this.
u
- URL to samplemethod
- HTTP method: GET, POST,...areFollowingRedirect
- whether we're getting a redirect targetdepth
- Depth of this target in the frame structure. Used only to
prevent infinite recursion.
protected HTTPSampleResult downloadPageResources(HTTPSampleResult res, HTTPSampleResult container, int frameDepth)
If createContainerResult is true, the returned result will contain one subsample for each request issued, including the original one that was passed in. It will otherwise look exactly like that original one.
If createContainerResult is false, one subsample will be added to the provided result for each requests issued.
res
- result of the initial request - must contain an HTML responsecontainer
- for storing the resultsframeDepth
- Depth of this target in the frame structure. Used only to
prevent infinite recursion.
protected java.lang.String encodeSpaces(java.lang.String path)
public void testEnded()
TestListener
Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.
N.B. testStarted() and testEnded() are called from different threads.
testEnded
in interface TestListener
StandardJMeterEngine.stopTest()
public void testEnded(java.lang.String host)
TestListener
Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.
N.B. testStarted() and testEnded() are called from different threads.
testEnded
in interface TestListener
StandardJMeterEngine.stopTest()
public void testIterationStart(LoopIterationEvent event)
TestListener
testIterationStart
in interface TestListener
public void testStarted()
TestListener
Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.
N.B. testStarted() and testEnded() are called from different threads.
testStarted
in interface TestListener
StandardJMeterEngine.run()
public void testStarted(java.lang.String host)
TestListener
Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.
N.B. testStarted() and testEnded() are called from different threads.
testStarted
in interface TestListener
StandardJMeterEngine.run()
public java.lang.Object clone()
clone
in interface TestElement
clone
in class AbstractTestElement
protected HTTPSampleResult followRedirects(HTTPSampleResult res, int frameDepth)
The returned result will contain one subsample for each request issued, including the original one that was passed in. It will be an HTTPSampleResult that should mostly look as if the final destination of the redirect chain had been obtained in a single shot.
res
- result of the initial request - must be a redirect responseframeDepth
- Depth of this target in the frame structure. Used only to
prevent infinite recursion.
protected HTTPSampleResult resultProcessing(boolean areFollowingRedirect, int frameDepth, HTTPSampleResult res)
areFollowingRedirect
- frameDepth
- res
-
protected boolean isSuccessCode(int code)
protected static java.lang.String encodeBackSlashes(java.lang.String value)
public HTTPFileArg[] getHTTPFiles()
public int getHTTPFileCount()
public void setHTTPFiles(HTTPFileArg[] files)
files
- list of files to savepublic static java.lang.String[] getValidMethodsAsArray()
public static boolean isSecure(java.lang.String protocol)
public static boolean isSecure(java.net.URL url)
public void threadStarted()
ThreadListener
threadStarted
in interface ThreadListener
JMeterThread.threadStarted()
public void threadFinished()
ThreadListener
threadFinished
in interface ThreadListener
JMeterThread.threadFinished()
public byte[] readResponse(SampleResult sampleResult, java.io.InputStream in, int length) throws java.io.IOException
sampleResult
- in
- input streamlength
- expected input length or zero
java.io.IOException
|
Apache JMeter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |