Class HTTPHC4Impl
java.lang.Object
org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl
org.apache.jmeter.protocol.http.sampler.HTTPHCAbstractImpl
org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl
- All Implemented Interfaces:
HTTPConstantsInterface, Interruptible
HTTP Sampler using Apache HttpClient 4.x.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class HTTPHCAbstractImpl
CPS_HTTP, CPS_HTTPS, HTTP_VERSION, localAddress, localHost, NONPROXY_HOSTS, nonProxyHostFull, nonProxyHostSuffix, nonProxyHostSuffixSize, PROXY_DEFINED, PROXY_DOMAIN, PROXY_HOST, PROXY_PASS, PROXY_PORT, PROXY_USER, SO_TIMEOUT, USE_CACHED_SSL_CONTEXT, USE_LOOPBACKFields inherited from class HTTPAbstractImpl
testElementFields inherited from interface HTTPConstantsInterface
APPLICATION_X_WWW_FORM_URLENCODED, CACHE_CONTROL, CONNECT, CONNECTION_CLOSE, COPY, DATE, DEFAULT_HTTP_PORT, DEFAULT_HTTP_PORT_STRING, DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_PORT_STRING, DELETE, ENCODING_GZIP, ETAG, EXPIRES, GET, HEAD, HEADER_AUTHORIZATION, HEADER_CONNECTION, HEADER_CONTENT_DISPOSITION, HEADER_CONTENT_ENCODING, HEADER_CONTENT_LENGTH, HEADER_CONTENT_TYPE, HEADER_COOKIE, HEADER_HOST, HEADER_LOCAL_ADDRESS, HEADER_LOCATION, HEADER_SET_COOKIE, HTTP_1_1, IF_MODIFIED_SINCE, IF_NONE_MATCH, KEEP_ALIVE, LAST_MODIFIED, LOCK, MKCALENDAR, MKCOL, MOVE, MULTIPART_FORM_DATA, OPTIONS, PATCH, POST, PROPFIND, PROPPATCH, PROTOCOL_HTTP, PROTOCOL_HTTPS, PUT, REPORT, TRACE, TRANSFER_ENCODING, UNLOCK -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected HTTPSampleResultcreateSampleResult(URL url, String method) Create HTTPSampleResult filling url, method and SampleLabel.protected StringgetCharsetWithDefault(HttpParams putParams) If contentEncoding is not set by user, then Platform encoding will be used to convert to Stringprotected voidhandleMethod(String method, HTTPSampleResult result, HttpRequestBase httpRequest, HttpContext localContext) CallssendPostData(HttpPost)if method isPOSTandsendEntityData(HttpEntityEnclosingRequestBase)if method isPUTorPATCHbooleanInterrupt the current operation if possible.protected voidprotected HTTPSampleResultprotected StringsendEntityData(HttpEntityEnclosingRequestBase entity) Creates the entity data to be sent.protected StringsendPostData(HttpPost post) protected StringsetConnectionCookie(HttpRequest request, URL url, CookieManager cookieManager) Extracts all the required cookies for that particular URL request and sets them in theHttpMethodpassed in.protected voidsetConnectionHeaders(HttpRequestBase request, URL url, HeaderManager headerManager, CacheManager cacheManager) Extracts all the required non-cookie headers for that particular URL request and sets them in theHttpMethodpassed inprotected voidsetDefaultRequestHeaders(HttpRequest request) Set any default request headers to includeprotected voidsetupRequest(URL url, HttpRequestBase httpRequest, HTTPSampleResult res) Setup following elements on httpRequest: ConnRoutePNames.LOCAL_ADDRESS enabling IP-SPOOFING Socket and connection timeout Redirect handling Keep Alive header or Connection Close Calls setConnectionHeaders to setup headers Calls setConnectionCookie to setup Cookieprotected voidMethods inherited from class HTTPHCAbstractImpl
isDynamicProxy, isNonProxy, isNullOrEmptyTrimmed, isPartialMatch, isStaticProxyMethods inherited from class HTTPAbstractImpl
errorResult, getArguments, getAuthManager, getAutoRedirects, getCacheManager, getConnectTimeout, getContentEncoding, getCookieManager, getDoBrowserCompatibleMultipart, getHeaderManager, getHTTPFiles, getIpSource, getIpSourceAddress, getProxyHost, getProxyPass, getProxyPortInt, getProxyUser, getResponseTimeout, getSendFileAsPostBody, getSendParameterValuesAsPostBody, getUseKeepAlive, getUseMultipartForPost, hasArguments, isMonitor, isSuccessCode, notifySSLContextWasReset, readResponse, readResponse, resultProcessing, setUseKeepAlive, updateSampleResultForResourceInCache
-
Constructor Details
-
HTTPHC4Impl
-
-
Method Details
-
sample
protected HTTPSampleResult sample(URL url, String method, boolean areFollowingRedirect, int frameDepth) - Specified by:
samplein classHTTPAbstractImpl
-
handleMethod
protected void handleMethod(String method, HTTPSampleResult result, HttpRequestBase httpRequest, HttpContext localContext) throws IOException CallssendPostData(HttpPost)if method isPOSTandsendEntityData(HttpEntityEnclosingRequestBase)if method isPUTorPATCHField HTTPSampleResult#queryString of result is modified in the 2 cases
- Parameters:
method- String HTTP methodresult-HTTPSampleResulthttpRequest-invalid reference
HttpRequestBaselocalContext-invalid reference
HttpContext- Throws:
IOException- when posting data fails due to I/O
-
createSampleResult
Create HTTPSampleResult filling url, method and SampleLabel. Monitor field is computed calling isMonitor()- Parameters:
url- URLmethod- HTTP Method- Returns:
HTTPSampleResult
-
setupRequest
protected void setupRequest(URL url, HttpRequestBase httpRequest, HTTPSampleResult res) throws IOException Setup following elements on httpRequest:- ConnRoutePNames.LOCAL_ADDRESS enabling IP-SPOOFING
- Socket and connection timeout
- Redirect handling
- Keep Alive header or Connection Close
- Calls setConnectionHeaders to setup headers
- Calls setConnectionCookie to setup Cookie
- Parameters:
url-URLof the requesthttpRequest- http request for the requestres- sample result to set cookies on- Throws:
IOException- if hostname/ip to use could not be figured out
-
setDefaultRequestHeaders
protected void setDefaultRequestHeaders(HttpRequest request) Set any default request headers to include- Parameters:
request- the HttpRequest to be used
-
setConnectionCookie
Extracts all the required cookies for that particular URL request and sets them in theHttpMethodpassed in.- Parameters:
request-HttpRequestfor the requesturl-URLof the requestcookieManager- theCookieManagercontaining all the cookies- Returns:
- a String containing the cookie details (for the response) May be null
-
setConnectionHeaders
protected void setConnectionHeaders(HttpRequestBase request, URL url, HeaderManager headerManager, CacheManager cacheManager) Extracts all the required non-cookie headers for that particular URL request and sets them in theHttpMethodpassed in- Parameters:
request-HttpRequestwhich represents the requesturl-URLof the URL requestheaderManager- theHeaderManagercontaining all the cookies for thisUrlConfigcacheManager- the CacheManager (may be null)
-
sendPostData
- Parameters:
post-invalid reference
HttpPost- Returns:
- String posted body if computable
- Throws:
IOException- if sending the data fails due to I/O
-
sendEntityData
Creates the entity data to be sent.If there is a file entry with a non-empty MIME type we use that to set the request Content-Type header, otherwise we default to whatever header is present from a Header Manager.
If the content charset
HTTPAbstractImpl.getContentEncoding()is null or empty we use the HC4 default provided bywhich is ISO-8859-1.invalid reference
HTTP#DEF_CONTENT_CHARSET- Parameters:
entity- to be processed, e.g. PUT or PATCH- Returns:
- the entity content, may be empty
- Throws:
UnsupportedEncodingException- for invalid charset nameIOException- cannot really occur for ByteArrayOutputStream methods
-
getCharsetWithDefault
If contentEncoding is not set by user, then Platform encoding will be used to convert to String- Parameters:
putParams-invalid reference
HttpParams- Returns:
- String charset
-
notifyFirstSampleAfterLoopRestart
protected void notifyFirstSampleAfterLoopRestart()- Overrides:
notifyFirstSampleAfterLoopRestartin classHTTPAbstractImpl
-
threadFinished
protected void threadFinished()- Overrides:
threadFinishedin classHTTPAbstractImpl
-
interrupt
public boolean interrupt()Description copied from interface:InterruptibleInterrupt the current operation if possible.- Returns:
trueif there was an operation to interrupt.
-