org.apache.jmeter.protocol.http.sampler

## Class HTTPAbstractImpl

- java.lang.Object
- - org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl

- All Implemented Interfaces:
    HTTPConstantsInterface, Interruptible
  Direct Known Subclasses:
    HTTPFileImpl, HTTPHCAbstractImpl, HTTPJavaImpl

      public abstract class HTTPAbstractImpl
      extends java.lang.Object
      implements Interruptible, HTTPConstantsInterface

  Base class for HTTP implementations used by the HTTPSamplerProxy sampler.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static boolean` | `ADD_CONTENT_TYPE_TO_POST_IF_MISSING` Should we add to POST request content-type header if missing: Content-Type: application/x-www-form-urlencoded
    `protected static java.util.function.Predicate<java.lang.String>` | `ALL_EXCEPT_COOKIE`
    `protected static java.util.function.Predicate<java.lang.String>` | `ONLY_COOKIE`
    `protected HTTPSamplerBase` | `testElement`

    - ### Fields inherited from interface org.apache.jmeter.protocol.http.util.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_BROTLI, ENCODING_DEFLATE, 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_COOKIE_IN_REQUEST, 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, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_SEE_OTHER, SC_TEMPORARY_REDIRECT, SEARCH, TRACE, TRANSFER_ENCODING, UNLOCK, VARY`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `HTTPAbstractImpl(HTTPSamplerBase testElement)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected HTTPSampleResult` | `errorResult(java.lang.Throwable t, HTTPSampleResult res)` Populates the provided HTTPSampleResult with details from the Exception.
    `protected Arguments` | `getArguments()` Invokes `HTTPSamplerBase.getArguments()`
    `protected AuthManager` | `getAuthManager()` Invokes `HTTPSamplerBase.getAuthManager()`
    `protected boolean` | `getAutoRedirects()` Invokes `HTTPSamplerBase.getAutoRedirects()`
    `protected CacheManager` | `getCacheManager()` Invokes `HTTPSamplerBase.getCacheManager()`
    `protected int` | `getConnectTimeout()` Invokes `HTTPSamplerBase.getConnectTimeout()`
    `protected java.lang.String` | `getContentEncoding()` Invokes `HTTPSamplerBase.getContentEncoding()`
    `protected CookieManager` | `getCookieManager()` Invokes `HTTPSamplerBase.getCookieManager()`
    `protected boolean` | `getDoBrowserCompatibleMultipart()` Invokes `HTTPSamplerBase.getDoBrowserCompatibleMultipart()`
    `protected HeaderManager` | `getHeaderManager()` Invokes `HTTPSamplerBase.getHeaderManager()`
    `protected HTTPFileArg[]` | `getHTTPFiles()` Get the collection of files as a list.
    `protected java.lang.String` | `getIpSource()` Invokes `HTTPSamplerBase.getIpSource()`
    `protected java.net.InetAddress` | `getIpSourceAddress()` Gets the IP source address (IP spoofing) if one has been provided.
    `protected java.lang.String` | `getProxyHost()` Invokes `HTTPSamplerBase.getProxyHost()`
    `protected java.lang.String` | `getProxyPass()` Invokes `HTTPSamplerBase.getProxyPass()`
    `protected int` | `getProxyPortInt()` Invokes `HTTPSamplerBase.getProxyPortInt()`
    `protected java.lang.String` | `getProxyUser()` Invokes `HTTPSamplerBase.getProxyUser()`
    `protected int` | `getResponseTimeout()` Invokes `HTTPSamplerBase.getResponseTimeout()`
    `protected boolean` | `getSendFileAsPostBody()` Determine whether to send a file as the entire body of an entity enclosing request such as POST, PUT or PATCH.
    `protected boolean` | `getSendParameterValuesAsPostBody()` Determine whether to send concatenated parameters as the entire body of an entity enclosing request such as POST, PUT or PATCH.
    `protected boolean` | `getUseKeepAlive()` Invokes `HTTPSamplerBase.getUseKeepAlive()`
    `protected boolean` | `getUseMultipart()` Determine if we should use `multipart/form-data` or `application/x-www-form-urlencoded` for the method Invokes `HTTPSamplerBase.getUseMultipart()`
    `protected boolean` | `getUseMultipartForPost()` Deprecated. Use `getUseMultipart()`
    `protected boolean` | `hasArguments()` Invokes `HTTPSamplerBase.hasArguments()`
    `protected boolean` | `isMonitor()` Deprecated. since 3.2 always return false
    `protected boolean` | `isSuccessCode(int errorLevel)` Determine if the HTTP status code is successful or not i.e. in range 200 to 399 inclusive Invokes `HTTPSamplerBase.isSuccessCode(int)`
    `protected void` | `notifyFirstSampleAfterLoopRestart()`
    `protected void` | `notifySSLContextWasReset()` Deprecated. ** unused since r1489189. **
    `protected byte[]` | `readResponse(SampleResult res, java.io.BufferedInputStream in, int contentLength)` Deprecated. use `readResponse(SampleResult, BufferedInputStream, long)`
    `protected byte[]` | `readResponse(SampleResult res, java.io.BufferedInputStream in, long contentLength)` Read response from the input stream, converting to MD5 digest if the useMD5 property is set.
    `protected byte[]` | `readResponse(SampleResult res, java.io.InputStream instream, int responseContentLength)` Read response from the input stream, converting to MD5 digest if the useMD5 property is set.
    `protected byte[]` | `readResponse(SampleResult res, java.io.InputStream instream, long responseContentLength)` 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.
    `protected abstract HTTPSampleResult` | `sample(java.net.URL url, java.lang.String method, boolean areFollowingRedirect, int frameDepth)`
    `protected void` | `setUseKeepAlive(boolean b)` Invokes `HTTPSamplerBase.setUseKeepAlive(boolean)`
    `protected void` | `threadFinished()`
    `protected HTTPSampleResult` | `updateSampleResultForResourceInCache(HTTPSampleResult res)` Update HTTPSampleResult for a resource in cache

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.jmeter.samplers.Interruptible

      `interrupt`

- - ### Field Detail

    - #### ADD_CONTENT_TYPE_TO_POST_IF_MISSING

          protected static final boolean ADD_CONTENT_TYPE_TO_POST_IF_MISSING

      Should we add to POST request content-type header if missing: Content-Type: application/x-www-form-urlencoded

    - #### ALL_EXCEPT_COOKIE

          protected static final java.util.function.Predicate<java.lang.String> ALL_EXCEPT_COOKIE

    - #### ONLY_COOKIE

          protected static final java.util.function.Predicate<java.lang.String> ONLY_COOKIE

    - #### testElement

          protected final HTTPSamplerBase testElement

  - ### Constructor Detail

    - #### HTTPAbstractImpl

          protected HTTPAbstractImpl(HTTPSamplerBase testElement)

  - ### Method Detail

    - #### sample

          protected abstract HTTPSampleResult sample(java.net.URL url,
                                                     java.lang.String method,
                                                     boolean areFollowingRedirect,
                                                     int frameDepth)

    - #### threadFinished

          protected void threadFinished()

    - #### notifyFirstSampleAfterLoopRestart

          protected void notifyFirstSampleAfterLoopRestart()

    - #### errorResult

          protected HTTPSampleResult errorResult(java.lang.Throwable t,
                                                 HTTPSampleResult res)

      Populates the provided HTTPSampleResult with details from the Exception. Does not create a new instance, so should not be used directly to add a subsample.

      See `HTTPSamplerBase.errorResult(Throwable, HTTPSampleResult)`

      Parameters:
        `t` - Exception representing the error.
        `res` - SampleResult to be modified
      Returns:
        the modified sampling result containing details of the Exception. Invokes

    - #### getArguments

          protected Arguments getArguments()

      Invokes `HTTPSamplerBase.getArguments()`
      Returns:
        the arguments of the associated test element

    - #### getAuthManager

          protected AuthManager getAuthManager()

      Invokes `HTTPSamplerBase.getAuthManager()`
      Returns:
        the `AuthManager` of the associated test element

    - #### getAutoRedirects

          protected boolean getAutoRedirects()

      Invokes `HTTPSamplerBase.getAutoRedirects()`
      Returns:
        flag whether to do auto redirects

    - #### getCacheManager

          protected CacheManager getCacheManager()

      Invokes `HTTPSamplerBase.getCacheManager()`
      Returns:
        the `CacheManager` of the associated test element

    - #### getConnectTimeout

          protected int getConnectTimeout()

      Invokes `HTTPSamplerBase.getConnectTimeout()`
      Returns:
        the connect timeout of the associated test element

    - #### getContentEncoding

          protected java.lang.String getContentEncoding()

      Invokes `HTTPSamplerBase.getContentEncoding()`
      Returns:
        the encoding of the content, i.e. its charset name

    - #### getCookieManager

          protected CookieManager getCookieManager()

      Invokes `HTTPSamplerBase.getCookieManager()`
      Returns:
        the `CookieManager` of the associated test element

    - #### getHeaderManager

          protected HeaderManager getHeaderManager()

      Invokes `HTTPSamplerBase.getHeaderManager()`
      Returns:
        the `HeaderManager` of the associated test element

    - #### getHTTPFiles

          protected 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.

      Invokes `HTTPSamplerBase.getHTTPFiles()`

      Returns:
        an array of file arguments (never `null`)

    - #### getIpSource

          protected java.lang.String getIpSource()

      Invokes `HTTPSamplerBase.getIpSource()`
      Returns:
        the configured ip source for the associated test element

    - #### getIpSourceAddress

          protected java.net.InetAddress getIpSourceAddress()
                                                     throws java.net.UnknownHostException,
                                                            java.net.SocketException

      Gets the IP source address (IP spoofing) if one has been provided.
      Returns:
        the IP source address to use (or `null`, if none provided or the device address could not be found)
      Throws:
        `java.net.UnknownHostException` - if the hostname/ip for `getIpSource()` could not be resolved or not interface was found for it
        `java.net.SocketException` - if an I/O error occurs

    - #### getProxyHost

          protected java.lang.String getProxyHost()

      Invokes `HTTPSamplerBase.getProxyHost()`
      Returns:
        the configured host to use as a proxy

    - #### getProxyPass

          protected java.lang.String getProxyPass()

      Invokes `HTTPSamplerBase.getProxyPass()`
      Returns:
        the configured password to use for the proxy

    - #### getProxyPortInt

          protected int getProxyPortInt()

      Invokes `HTTPSamplerBase.getProxyPortInt()`
      Returns:
        the configured port to use for the proxy

    - #### getProxyUser

          protected java.lang.String getProxyUser()

      Invokes `HTTPSamplerBase.getProxyUser()`
      Returns:
        the configured user to use for the proxy

    - #### getResponseTimeout

          protected int getResponseTimeout()

      Invokes `HTTPSamplerBase.getResponseTimeout()`
      Returns:
        the configured timeout for responses

    - #### getSendFileAsPostBody

          protected boolean getSendFileAsPostBody()

      Determine whether to send a file as the entire body of an entity enclosing request such as POST, PUT or PATCH. Invokes `HTTPSamplerBase.getSendFileAsPostBody()`
      Returns:
        flag whether to send a file as POST, PUT or PATCH

    - #### getSendParameterValuesAsPostBody

          protected boolean getSendParameterValuesAsPostBody()

      Determine whether to send concatenated parameters as the entire body of an entity enclosing request such as POST, PUT or PATCH. Invokes `HTTPSamplerBase.getSendParameterValuesAsPostBody()`
      Returns:
        flag whether to send concatenated parameters as the entire body

    - #### getUseKeepAlive

          protected boolean getUseKeepAlive()

      Invokes `HTTPSamplerBase.getUseKeepAlive()`
      Returns:
        flag whether to use keep-alive for requests

    - #### getUseMultipartForPost

          @Deprecated
          protected boolean getUseMultipartForPost()

      Deprecated. Use `getUseMultipart()`
      Determine if we should use `multipart/form-data` or `application/x-www-form-urlencoded` for the post

      Invokes `HTTPSamplerBase.getUseMultipartForPost()`

      Returns:
        `true` if `multipart/form-data` should be used and method is POST

    - #### getUseMultipart

          protected boolean getUseMultipart()

      Determine if we should use `multipart/form-data` or `application/x-www-form-urlencoded` for the method

      Invokes `HTTPSamplerBase.getUseMultipart()`

      Returns:
        `true` if `multipart/form-data` should be used

    - #### getDoBrowserCompatibleMultipart

          protected boolean getDoBrowserCompatibleMultipart()

      Invokes `HTTPSamplerBase.getDoBrowserCompatibleMultipart()`
      Returns:
        flag whether we should do browser compatible multiparts

    - #### hasArguments

          protected boolean hasArguments()

      Invokes `HTTPSamplerBase.hasArguments()`
      Returns:
        flag whether we have arguments to send

    - #### isMonitor

          @Deprecated
          protected boolean isMonitor()

      Deprecated. since 3.2 always return false
      Invokes `HTTPSamplerBase.isMonitor()`
      Returns:
        flag whether monitor is enabled

    - #### isSuccessCode

          protected boolean isSuccessCode(int errorLevel)

      Determine if the HTTP status code is successful or not i.e. in range 200 to 399 inclusive

      Invokes `HTTPSamplerBase.isSuccessCode(int)`

      Parameters:
        `errorLevel` - status code to check
      Returns:
        whether in range 200-399 or not

    - #### readResponse

          protected byte[] readResponse(SampleResult res,
                                        java.io.InputStream instream,
                                        int responseContentLength)
                                 throws java.io.IOException

      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

      Invokes `HTTPSamplerBase.readResponse(SampleResult, InputStream, long)`

      Parameters:
        `res` - sample to store information about the response into
        `instream` - input stream from which to read the response
        `responseContentLength` - expected input length or zero
      Returns:
        the response or the MD5 of the response
      Throws:
        `java.io.IOException` - if reading the result fails

    - #### readResponse

          protected byte[] readResponse(SampleResult res,
                                        java.io.InputStream instream,
                                        long responseContentLength)
                                 throws java.io.IOException

      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

      Invokes `HTTPSamplerBase.readResponse(SampleResult, InputStream, long)`

      Parameters:
        `res` - sample to store information about the response into
        `instream` - input stream from which to read the response
        `responseContentLength` - expected input length or zero
      Returns:
        the response or the MD5 of the response
      Throws:
        `java.io.IOException` - if reading the result fails

    - #### readResponse

          @Deprecated
          protected byte[] readResponse(SampleResult res,
                                                    java.io.BufferedInputStream in,
                                                    int contentLength)
                                             throws java.io.IOException

      Deprecated. use `readResponse(SampleResult, BufferedInputStream, long)`
      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

      Invokes `HTTPSamplerBase.readResponse(SampleResult, InputStream, long)`

      Parameters:
        `res` - sample to store information about the response into
        `in` - input stream from which to read the response
        `contentLength` - expected input length or zero
      Returns:
        the response or the MD5 of the response
      Throws:
        `java.io.IOException` - when reading the result fails

    - #### readResponse

          protected byte[] readResponse(SampleResult res,
                                        java.io.BufferedInputStream in,
                                        long contentLength)
                                 throws java.io.IOException

      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

      Invokes `HTTPSamplerBase.readResponse(SampleResult, InputStream, long)`

      Parameters:
        `res` - sample to store information about the response into
        `in` - input stream from which to read the response
        `contentLength` - expected input length or zero
      Returns:
        the response or the MD5 of the response
      Throws:
        `java.io.IOException` - when reading the result fails

    - #### resultProcessing

          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.

      Invokes `HTTPSamplerBase.resultProcessing(boolean, int, HTTPSampleResult)`

      Parameters:
        `areFollowingRedirect` - flag whether we are getting a redirect target
        `frameDepth` - Depth of this target in the frame structure. Used only to prevent infinite recursion.
        `res` - sample result to process
      Returns:
        the sample result

    - #### setUseKeepAlive

          protected void setUseKeepAlive(boolean b)

      Invokes `HTTPSamplerBase.setUseKeepAlive(boolean)`
      Parameters:
        `b` - flag whether to use keep-alive for requests

    - #### notifySSLContextWasReset

          @Deprecated
          protected void notifySSLContextWasReset()

      Deprecated. ** unused since r1489189. **
      Called by testIterationStart if the SSL Context was reset. This implementation does nothing.

    - #### updateSampleResultForResourceInCache

          protected HTTPSampleResult updateSampleResultForResourceInCache(HTTPSampleResult res)

      Update HTTPSampleResult for a resource in cache
      Parameters:
        `res` - `HTTPSampleResult`
      Returns:
        HTTPSampleResult

Copyright © 1998-2018 Apache Software Foundation. All Rights Reserved.