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 booleanallowClosingHttpClientprotected booleanchunkedprotected booleanclosedprotected org.apache.http.HttpHostdefaultProxyprotected intfileUploadInMemoryThresholdLimitFor uploading File's over JAX-RS framework, this property, together withfileUploadMemoryUnit, defines the maximum File size allowed in memory.protected ApacheHttpClientEngine.MemoryUnitfileUploadMemoryUnitThe unit forfileUploadInMemoryThresholdLimit.protected FilefileUploadTempFileDirTemp directory to write output request stream to.protected booleanfollowRedirectsprotected HostnameVerifierhostnameVerifierprotected org.apache.http.client.HttpClienthttpClientprotected HttpContextProviderhttpContextProviderprotected intresponseBufferSizeprotected SSLContextsslContext
-
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.HttpEntitybuildEntity(ClientInvocation request)Build the HttpEntity to be sent to the Service as part of (POST) request.protected voidcleanUpAfterExecute(org.apache.http.client.methods.HttpRequestBase httpMethod)If passed httpMethod is of type HttpPost then obtain its entity.voidclose()protected voidcommitHeaders(ClientInvocation request, org.apache.http.client.methods.HttpRequestBase httpMethod)protected InputStreamcreateBufferedStream(InputStream is)protected org.apache.http.client.HttpClientcreateDefaultHttpClient()protected org.apache.http.client.methods.HttpRequestBasecreateHttpMethod(String url, String restVerb)static CaseInsensitiveMap<String>extractHeaders(org.apache.http.HttpResponse response)org.apache.http.HttpHostgetDefaultProxy()intgetFileUploadInMemoryThresholdLimit()Based on memory unitApacheHttpClientEngine.MemoryUnitgetFileUploadMemoryUnit()FilegetFileUploadTempFileDir()HostnameVerifiergetHostnameVerifier()Needed for Client.getHostnameVerifier()org.apache.http.client.HttpClientgetHttpClient()intgetResponseBufferSize()Response stream is wrapped in a BufferedInputStream.SSLContextgetSslContext()Needed for Client.getSslContext();protected StringgetTempfilePrefix()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.Responseinvoke(javax.ws.rs.client.Invocation inv)booleanisChunked()booleanisClosed()booleanisFollowRedirects()protected voidloadHttpMethod(ClientInvocation request, org.apache.http.client.methods.HttpRequestBase httpMethod)voidsetChunked(boolean chunked)voidsetFileUploadInMemoryThresholdLimit(int fileUploadInMemoryThresholdLimit)voidsetFileUploadMemoryUnit(ApacheHttpClientEngine.MemoryUnit fileUploadMemoryUnit)voidsetFileUploadTempFileDir(File fileUploadTempFileDir)voidsetFollowRedirects(boolean followRedirects)voidsetHostnameVerifier(HostnameVerifier hostnameVerifier)protected voidsetRedirectNotRequired(ClientInvocation request, org.apache.http.client.methods.HttpRequestBase httpMethod)protected voidsetRedirectRequired(ClientInvocation request, org.apache.http.client.methods.HttpRequestBase httpMethod)voidsetResponseBufferSize(int responseBufferSize)Response stream is wrapped in a BufferedInputStream.voidsetSslContext(SSLContext sslContext)
-
-
-
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 withfileUploadMemoryUnit, defines the maximum File size allowed in memory. If fileSize exceeds this size, it will be stored tofileUploadTempFileDir.
Defaults to 1 MB
-
fileUploadMemoryUnit
protected ApacheHttpClientEngine.MemoryUnit fileUploadMemoryUnit
- 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:ClientHttpEngineNeeded for Client.getSslContext();- Specified by:
getSslContextin interfaceClientHttpEngine- Returns:
SSLContext
-
setSslContext
public void setSslContext(SSLContext sslContext)
-
getHostnameVerifier
public HostnameVerifier getHostnameVerifier()
Description copied from interface:ClientHttpEngineNeeded for Client.getHostnameVerifier()- Specified by:
getHostnameVerifierin interfaceClientHttpEngine- 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:
invokein interfaceClientHttpEngine
-
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:
isFollowRedirectsin interfaceClientHttpEngine
-
setFollowRedirects
public void setFollowRedirects(boolean followRedirects)
- Specified by:
setFollowRedirectsin interfaceClientHttpEngine
-
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-memoryManualClosingApacheHttpClient43Engine.FileExposingFileEntityor a regular in-memoryByteArrayEntitydepending 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:
closein interfaceClientHttpEngine
-
-