public class DefaultConnection extends Object implements PooledConnection
Connection
implementation based on HttpClient
.Modifier and Type | Field and Description |
---|---|
protected org.apache.http.impl.client.CloseableHttpClient |
httpClient |
protected org.apache.http.client.config.RequestConfig |
requestConfig |
Modifier | Constructor and Description |
---|---|
protected |
DefaultConnection(DefaultConnectionBuilder builder) |
|
DefaultConnection(int connectTimeout,
int socketTimeout)
Creates a new connection with the given timeouts, the default number of maximum connections, no proxy and the default HTTPS protocols.
|
|
DefaultConnection(int connectTimeout,
int socketTimeout,
int maxConnections)
Creates a new connection with the given timeouts and number of maximum connections, no proxy and the default HTTPS protocols.
|
|
DefaultConnection(int connectTimeout,
int socketTimeout,
int maxConnections,
ProxyConfiguration proxyConfiguration)
Creates a new connection with the given timeouts, number of maximum connections and proxy configuration, and the default HTTPS protocols.
|
|
DefaultConnection(int connectTimeout,
int socketTimeout,
int maxConnections,
ProxyConfiguration proxyConfiguration,
Set<String> httpsProtocols)
Creates a new connection with the given timeouts, number of maximum connections, proxy configuration and HTTPS protocols.
|
|
DefaultConnection(int connectTimeout,
int socketTimeout,
int maxConnections,
ProxyConfiguration proxyConfiguration,
org.apache.http.conn.ssl.SSLConnectionSocketFactory sslConnectionSocketFactory)
Creates a new connection with the given timeouts, number of maximum connections, proxy configuration and SSL connection socket factory.
|
|
DefaultConnection(int connectTimeout,
int socketTimeout,
ProxyConfiguration proxyConfiguration)
Creates a new connection with the given timeouts and proxy configuration, the default number of maximum connections and the default HTTPS protocols.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addHeaders(org.apache.http.client.methods.HttpRequestBase httpRequestBase,
List<RequestHeader> requestHeaders) |
void |
close()
Releases any system resources associated with this object.
|
void |
closeExpiredConnections()
Closes all expired HTTP connections.
|
void |
closeIdleConnections(long idleTime,
TimeUnit timeUnit)
Closes all HTTP connections that have been idle for the specified time.
|
<R> R |
delete(URI uri,
List<RequestHeader> requestHeaders,
ResponseHandler<R> responseHandler)
Send a DELETE request to the Worldline Global Collect platform.
|
void |
disableLogging()
Turns off logging.
|
void |
enableLogging(CommunicatorLogger communicatorLogger)
Turns on logging using the given communicator logger.
|
protected <R> R |
executeRequest(org.apache.http.client.methods.HttpUriRequest request,
ResponseHandler<R> responseHandler) |
<R> R |
get(URI uri,
List<RequestHeader> requestHeaders,
ResponseHandler<R> responseHandler)
Send a GET request to the Worldline Global Collect platform.
|
protected List<ResponseHeader> |
getHeaders(org.apache.http.HttpResponse httpResponse) |
<R> R |
post(URI uri,
List<RequestHeader> requestHeaders,
MultipartFormDataObject multipart,
ResponseHandler<R> responseHandler)
Send a multipart/form-data POST request to the Worldline Global Collect platform.
|
<R> R |
post(URI uri,
List<RequestHeader> requestHeaders,
String body,
ResponseHandler<R> responseHandler)
Send a POST request to the Worldline Global Collect platform.
|
<R> R |
put(URI uri,
List<RequestHeader> requestHeaders,
MultipartFormDataObject multipart,
ResponseHandler<R> responseHandler)
Send a multipart/form-data PUT request to the Worldline Global Collect platform.
|
<R> R |
put(URI uri,
List<RequestHeader> requestHeaders,
String body,
ResponseHandler<R> responseHandler)
Send a PUT request to the Worldline Global Collect platform.
|
void |
setBodyObfuscator(BodyObfuscator bodyObfuscator)
Sets the current non-
null body obfuscator to use. |
void |
setHeaderObfuscator(HeaderObfuscator headerObfuscator)
Sets the current non-
null header obfuscator to use. |
protected final org.apache.http.impl.client.CloseableHttpClient httpClient
protected final org.apache.http.client.config.RequestConfig requestConfig
public DefaultConnection(int connectTimeout, int socketTimeout)
public DefaultConnection(int connectTimeout, int socketTimeout, int maxConnections)
public DefaultConnection(int connectTimeout, int socketTimeout, ProxyConfiguration proxyConfiguration)
public DefaultConnection(int connectTimeout, int socketTimeout, int maxConnections, ProxyConfiguration proxyConfiguration)
public DefaultConnection(int connectTimeout, int socketTimeout, int maxConnections, ProxyConfiguration proxyConfiguration, Set<String> httpsProtocols)
public DefaultConnection(int connectTimeout, int socketTimeout, int maxConnections, ProxyConfiguration proxyConfiguration, org.apache.http.conn.ssl.SSLConnectionSocketFactory sslConnectionSocketFactory)
protected DefaultConnection(DefaultConnectionBuilder builder)
public void close() throws IOException
Connection
close
in interface Connection
close
in interface Closeable
close
in interface AutoCloseable
IOException
public <R> R get(URI uri, List<RequestHeader> requestHeaders, ResponseHandler<R> responseHandler)
Connection
get
in interface Connection
uri
- The URI to call, including any necessary query parameters.requestHeaders
- An optional list of request headers.responseHandler
- A handler for the response.public <R> R delete(URI uri, List<RequestHeader> requestHeaders, ResponseHandler<R> responseHandler)
Connection
delete
in interface Connection
uri
- The URI to call, including any necessary query parameters.requestHeaders
- An optional list of request headers.responseHandler
- A handler for the response.public <R> R post(URI uri, List<RequestHeader> requestHeaders, String body, ResponseHandler<R> responseHandler)
Connection
post
in interface Connection
uri
- The URI to call, including any necessary query parameters.requestHeaders
- An optional list of request headers.body
- The optional body to send.responseHandler
- A handler for the response.public <R> R post(URI uri, List<RequestHeader> requestHeaders, MultipartFormDataObject multipart, ResponseHandler<R> responseHandler)
Connection
The content type of the request will be be part of the given request header list.
If the connection creates its own content type, it should be multipart.getContentType()
.
Otherwise, authentication failures will occur.
post
in interface Connection
uri
- The URI to call, including any necessary query parameters.requestHeaders
- An optional list of request headers.multipart
- The multipart/form-data request to send.responseHandler
- A handler for the response.public <R> R put(URI uri, List<RequestHeader> requestHeaders, String body, ResponseHandler<R> responseHandler)
Connection
put
in interface Connection
uri
- The URI to call, including any necessary query parameters.requestHeaders
- An optional list of request headers.body
- The optional body to send.responseHandler
- A handler for the response.public <R> R put(URI uri, List<RequestHeader> requestHeaders, MultipartFormDataObject multipart, ResponseHandler<R> responseHandler)
Connection
The content type of the request will be be part of the given request header list.
If the connection creates its own content type, it should be multipart.getContentType()
.
Otherwise, authentication failures will occur.
put
in interface Connection
uri
- The URI to call, including any necessary query parameters.requestHeaders
- An optional list of request headers.multipart
- The multipart/form-data request to send.responseHandler
- A handler for the response.protected <R> R executeRequest(org.apache.http.client.methods.HttpUriRequest request, ResponseHandler<R> responseHandler)
protected void addHeaders(org.apache.http.client.methods.HttpRequestBase httpRequestBase, List<RequestHeader> requestHeaders)
protected List<ResponseHeader> getHeaders(org.apache.http.HttpResponse httpResponse)
public void closeIdleConnections(long idleTime, TimeUnit timeUnit)
PooledConnection
closeIdleConnections
in interface PooledConnection
PooledConnection.closeExpiredConnections()
public void closeExpiredConnections()
PooledConnection
closeExpiredConnections
in interface PooledConnection
public void setBodyObfuscator(BodyObfuscator bodyObfuscator)
ObfuscationCapable
null
body obfuscator to use.setBodyObfuscator
in interface ObfuscationCapable
public void setHeaderObfuscator(HeaderObfuscator headerObfuscator)
ObfuscationCapable
null
header obfuscator to use.setHeaderObfuscator
in interface ObfuscationCapable
public void enableLogging(CommunicatorLogger communicatorLogger)
LoggingCapable
enableLogging
in interface LoggingCapable
public void disableLogging()
LoggingCapable
disableLogging
in interface LoggingCapable
Copyright © 2024 Worldline Global Collect. All rights reserved.