Package org.jboss.resteasy.client.jaxrs.engines

## Class ManualClosingApacheHttpClient43Engine

- java.lang.Object
- - org.jboss.resteasy.client.jaxrs.engines.ManualClosingApacheHttpClient43Engine

- All Implemented Interfaces:
    `ClientHttpEngine`, `ApacheHttpClientEngine`
  Direct Known Subclasses:
    `ApacheHttpClient43Engine`

      public class ManualClosingApacheHttpClient43Engine
      extends Object
      implements ApacheHttpClientEngine

  An Apache HTTP engine for use with the new Builder Config style.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClientEngine

      `ApacheHttpClientEngine.MemoryUnit`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected boolean` | `allowClosingHttpClient` |
    `protected boolean` | `chunked` |
    `protected boolean` | `closed` |
    `protected org.apache.http.HttpHost` | `defaultProxy` |
    `protected int` | `fileUploadInMemoryThresholdLimit` | For uploading File's over JAX-RS framework, this property, together with `fileUploadMemoryUnit`, defines the maximum File size allowed in memory.
    `protected ApacheHttpClientEngine.MemoryUnit` | `fileUploadMemoryUnit` | The unit for `fileUploadInMemoryThresholdLimit`.
    `protected File` | `fileUploadTempFileDir` | Temp directory to write output request stream to.
    `protected boolean` | `followRedirects` |
    `protected HostnameVerifier` | `hostnameVerifier` |
    `protected org.apache.http.client.HttpClient` | `httpClient` |
    `protected HttpContextProvider` | `httpContextProvider` |
    `protected int` | `responseBufferSize` |
    `protected SSLContext` | `sslContext` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ManualClosingApacheHttpClient43Engine()` |
    `ManualClosingApacheHttpClient43Engine​(org.apache.http.client.HttpClient httpClient)` |
    `ManualClosingApacheHttpClient43Engine​(org.apache.http.client.HttpClient httpClient, boolean closeHttpClient)` |
    `ManualClosingApacheHttpClient43Engine​(org.apache.http.client.HttpClient httpClient, HttpContextProvider httpContextProvider)` |
    `ManualClosingApacheHttpClient43Engine​(org.apache.http.HttpHost defaultProxy)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected org.apache.http.HttpEntity` | `buildEntity​(ClientInvocation request)` | Build the HttpEntity to be sent to the Service as part of (POST) request.
    `protected void` | `cleanUpAfterExecute​(org.apache.http.client.methods.HttpRequestBase httpMethod)` | If passed httpMethod is of type HttpPost then obtain its entity.
    `void` | `close()` |
    `protected void` | `commitHeaders​(ClientInvocation request, org.apache.http.client.methods.HttpRequestBase httpMethod)` |
    `protected InputStream` | `createBufferedStream​(InputStream is)` |
    `protected org.apache.http.client.HttpClient` | `createDefaultHttpClient()` |
    `protected org.apache.http.client.methods.HttpRequestBase` | `createHttpMethod​(String url, String restVerb)` |
    `static CaseInsensitiveMap<String>` | `extractHeaders​(org.apache.http.HttpResponse response)` |
    `org.apache.http.HttpHost` | `getDefaultProxy()` |
    `int` | `getFileUploadInMemoryThresholdLimit()` | Based on memory unit
    `ApacheHttpClientEngine.MemoryUnit` | `getFileUploadMemoryUnit()` |
    `File` | `getFileUploadTempFileDir()` |
    `HostnameVerifier` | `getHostnameVerifier()` | Needed for Client.getHostnameVerifier()
    `org.apache.http.client.HttpClient` | `getHttpClient()` |
    `int` | `getResponseBufferSize()` | Response stream is wrapped in a BufferedInputStream.
    `SSLContext` | `getSslContext()` | Needed for Client.getSslContext();
    `protected String` | `getTempfilePrefix()` | Use context information, which will include node name, to avoid conflicts in case of multiple VMS using same temp directory location.
    `javax.ws.rs.core.Response` | `invoke​(javax.ws.rs.client.Invocation inv)` |
    `boolean` | `isChunked()` |
    `boolean` | `isClosed()` |
    `boolean` | `isFollowRedirects()` |
    `protected void` | `loadHttpMethod​(ClientInvocation request, org.apache.http.client.methods.HttpRequestBase httpMethod)` |
    `void` | `setChunked​(boolean chunked)` |
    `void` | `setFileUploadInMemoryThresholdLimit​(int fileUploadInMemoryThresholdLimit)` |
    `void` | `setFileUploadMemoryUnit​(ApacheHttpClientEngine.MemoryUnit fileUploadMemoryUnit)` |
    `void` | `setFileUploadTempFileDir​(File fileUploadTempFileDir)` |
    `void` | `setFollowRedirects​(boolean followRedirects)` |
    `void` | `setHostnameVerifier​(HostnameVerifier hostnameVerifier)` |
    `protected void` | `setRedirectNotRequired​(ClientInvocation request, org.apache.http.client.methods.HttpRequestBase httpMethod)` |
    `protected void` | `setRedirectRequired​(ClientInvocation request, org.apache.http.client.methods.HttpRequestBase httpMethod)` |
    `void` | `setResponseBufferSize​(int responseBufferSize)` | Response stream is wrapped in a BufferedInputStream.
    `void` | `setSslContext​(SSLContext sslContext)` |

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

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

- - ### Field Detail

    - #### httpClient

          protected final org.apache.http.client.HttpClient httpClient

    - #### closed

          protected boolean closed

    - #### allowClosingHttpClient

          protected final boolean allowClosingHttpClient

    - #### httpContextProvider

          protected HttpContextProvider httpContextProvider

    - #### sslContext

          protected SSLContext sslContext

    - #### hostnameVerifier

          protected HostnameVerifier hostnameVerifier

    - #### responseBufferSize

          protected int responseBufferSize

    - #### defaultProxy

          protected org.apache.http.HttpHost defaultProxy

    - #### chunked

          protected boolean chunked

    - #### followRedirects

          protected boolean followRedirects

    - #### fileUploadInMemoryThresholdLimit

          protected int fileUploadInMemoryThresholdLimit

      For uploading File's over JAX-RS framework, this property, together with `fileUploadMemoryUnit`, defines the maximum File size allowed in memory. If fileSize exceeds this size, it will be stored to `fileUploadTempFileDir`.
      Defaults to 1 MB

    - #### fileUploadMemoryUnit

          protected ApacheHttpClientEngine.MemoryUnit fileUploadMemoryUnit

      The unit for `fileUploadInMemoryThresholdLimit`.
      Defaults to MB.
      See Also:
        `ApacheHttpClientEngine.MemoryUnit`

    - #### fileUploadTempFileDir

          protected File fileUploadTempFileDir

      Temp directory to write output request stream to. Any file to be uploaded has to be written out to the output request stream to be sent to the service and when the File is too huge the output request stream is written out to the disk rather than to memory.
      Defaults to JVM temp directory.

  - ### Constructor Detail

    - #### ManualClosingApacheHttpClient43Engine

          public ManualClosingApacheHttpClient43Engine()

    - #### ManualClosingApacheHttpClient43Engine

          public ManualClosingApacheHttpClient43Engine​(org.apache.http.HttpHost defaultProxy)

    - #### ManualClosingApacheHttpClient43Engine

          public ManualClosingApacheHttpClient43Engine​(org.apache.http.client.HttpClient httpClient)

    - #### ManualClosingApacheHttpClient43Engine

          public ManualClosingApacheHttpClient43Engine​(org.apache.http.client.HttpClient httpClient,
                                                       boolean closeHttpClient)

    - #### ManualClosingApacheHttpClient43Engine

          public ManualClosingApacheHttpClient43Engine​(org.apache.http.client.HttpClient httpClient,
                                                       HttpContextProvider httpContextProvider)

  - ### Method Detail

    - #### getResponseBufferSize

          public int getResponseBufferSize()

      Response stream is wrapped in a BufferedInputStream. Default is 8192. Value of 0 will not wrap it. Value of -1 will use a SelfExpandingBufferedInputStream
      Returns:
        response buffer size

    - #### setResponseBufferSize

          public void setResponseBufferSize​(int responseBufferSize)

      Response stream is wrapped in a BufferedInputStream. Default is 8192. Value of 0 will not wrap it. Value of -1 will use a SelfExpandingBufferedInputStream
      Parameters:
        `responseBufferSize` - response buffer size

    - #### getFileUploadInMemoryThresholdLimit

          public int getFileUploadInMemoryThresholdLimit()

      Based on memory unit
      Returns:
        threshold limit

    - #### setFileUploadInMemoryThresholdLimit

          public void setFileUploadInMemoryThresholdLimit​(int fileUploadInMemoryThresholdLimit)

    - #### getFileUploadMemoryUnit

          public ApacheHttpClientEngine.MemoryUnit getFileUploadMemoryUnit()

    - #### setFileUploadMemoryUnit

          public void setFileUploadMemoryUnit​(ApacheHttpClientEngine.MemoryUnit fileUploadMemoryUnit)

    - #### getFileUploadTempFileDir

          public File getFileUploadTempFileDir()

    - #### setFileUploadTempFileDir

          public void setFileUploadTempFileDir​(File fileUploadTempFileDir)

    - #### getHttpClient

          public org.apache.http.client.HttpClient getHttpClient()

    - #### getSslContext

          public SSLContext getSslContext()

      Description copied from interface: `ClientHttpEngine`
      Needed for Client.getSslContext();
      Specified by:
        `getSslContext` in interface `ClientHttpEngine`
      Returns:
        `SSLContext`

    - #### setSslContext

          public void setSslContext​(SSLContext sslContext)

    - #### getHostnameVerifier

          public HostnameVerifier getHostnameVerifier()

      Description copied from interface: `ClientHttpEngine`
      Needed for Client.getHostnameVerifier()
      Specified by:
        `getHostnameVerifier` in interface `ClientHttpEngine`
      Returns:
        `HostnameVerifier`

    - #### setHostnameVerifier

          public void setHostnameVerifier​(HostnameVerifier hostnameVerifier)

    - #### extractHeaders

          public static CaseInsensitiveMap<String> extractHeaders​(org.apache.http.HttpResponse response)

    - #### createBufferedStream

          protected InputStream createBufferedStream​(InputStream is)

    - #### invoke

          public javax.ws.rs.core.Response invoke​(javax.ws.rs.client.Invocation inv)

      Specified by:
        `invoke` in interface `ClientHttpEngine`

    - #### createHttpMethod

          protected org.apache.http.client.methods.HttpRequestBase createHttpMethod​(String url,
                                                                                    String restVerb)

    - #### loadHttpMethod

          protected void loadHttpMethod​(ClientInvocation request,
                                        org.apache.http.client.methods.HttpRequestBase httpMethod)
                                 throws Exception

      Throws:
        `Exception`

    - #### commitHeaders

          protected void commitHeaders​(ClientInvocation request,
                                       org.apache.http.client.methods.HttpRequestBase httpMethod)

    - #### isChunked

          public boolean isChunked()

    - #### setChunked

          public void setChunked​(boolean chunked)

    - #### isFollowRedirects

          public boolean isFollowRedirects()

      Specified by:
        `isFollowRedirects` in interface `ClientHttpEngine`

    - #### setFollowRedirects

          public void setFollowRedirects​(boolean followRedirects)

      Specified by:
        `setFollowRedirects` in interface `ClientHttpEngine`

    - #### cleanUpAfterExecute

          protected void cleanUpAfterExecute​(org.apache.http.client.methods.HttpRequestBase httpMethod)

      If passed httpMethod is of type HttpPost then obtain its entity. If the entity has an enclosing File then delete it by invoking this method after the request has completed. The entity will have an enclosing File only if it was too huge to fit into memory.
      Parameters:
        `httpMethod` - - the httpMethod to clean up.

    - #### buildEntity

          protected org.apache.http.HttpEntity buildEntity​(ClientInvocation request)
                                                    throws IOException

      Build the HttpEntity to be sent to the Service as part of (POST) request. Creates a off-memory `ManualClosingApacheHttpClient43Engine.FileExposingFileEntity` or a regular in-memory `ByteArrayEntity` depending on if the request OutputStream fit into memory when built by calling.
      Parameters:
        `request` - -
      Returns:
        - the built HttpEntity
      Throws:
        `IOException` - -

    - #### getTempfilePrefix

          protected String getTempfilePrefix()

      Use context information, which will include node name, to avoid conflicts in case of multiple VMS using same temp directory location.
      Returns:
        -

    - #### createDefaultHttpClient

          protected org.apache.http.client.HttpClient createDefaultHttpClient()

    - #### getDefaultProxy

          public org.apache.http.HttpHost getDefaultProxy()

    - #### setRedirectRequired

          protected void setRedirectRequired​(ClientInvocation request,
                                             org.apache.http.client.methods.HttpRequestBase httpMethod)

    - #### setRedirectNotRequired

          protected void setRedirectNotRequired​(ClientInvocation request,
                                                org.apache.http.client.methods.HttpRequestBase httpMethod)

    - #### isClosed

          public boolean isClosed()

    - #### close

          public void close()

      Specified by:
        `close` in interface `ClientHttpEngine`