public abstract class AbstractHttpClientWagon extends StreamWagon
Modifier and Type | Class and Description |
---|---|
(package private) class |
AbstractHttpClientWagon.WagonHttpEntity |
Modifier and Type | Field and Description |
---|---|
private org.apache.http.client.AuthCache |
authCache |
private BasicAuthScope |
basicAuth
Basic auth scope overrides
|
private java.io.Closeable |
closeable |
private static long |
CONN_TTL
Time to live in seconds for an HTTP connection.
|
private org.apache.http.client.CredentialsProvider |
credentialsProvider |
private static java.util.TimeZone |
GMT_TIME_ZONE |
private static org.apache.http.impl.client.CloseableHttpClient |
httpClient |
private static org.apache.http.conn.HttpClientConnectionManager |
httpClientConnectionManager
Internal connection manager
|
private HttpConfiguration |
httpConfiguration |
private java.util.Properties |
httpHeaders
Deprecated.
Use httpConfiguration instead.
|
private static boolean |
IGNORE_SSL_VALIDITY_DATES
if using sslInsecure, certificate date issues will be ignored
disabled by default
|
private int |
initialBackoffSeconds
Initial seconds to back off when a HTTP 429 received.
|
private static int |
MAX_BACKOFF_WAIT_SECONDS
The maximum amount of time we want to back off in the case of
repeated HTTP 429 response codes.
|
private static int |
MAX_CONN_PER_ROUTE
Maximum concurrent connections per distinct route.
|
private static int |
MAX_CONN_TOTAL
Maximum concurrent connections in total.
|
private static boolean |
persistentPool
use http(s) connection pool mechanism.
|
private BasicAuthScope |
proxyAuth
Proxy basic auth scope overrides
|
private static java.lang.String |
RETRY_HANDLER_CLASS
The type of the retry handler, defaults to
standard . |
private static int |
RETRY_HANDLER_COUNT
Number of retries for the retry handler, defaults to 3.
|
private static java.lang.String |
RETRY_HANDLER_EXCEPTIONS
Comma-separated list of non-retryable exception classes.
|
private static boolean |
RETRY_HANDLER_REQUEST_SENT_ENABLED
Whether or not methods that have successfully sent their request will be retried,
defaults to
false . |
protected static int |
SC_TOO_MANY_REQUESTS
See RFC6585
|
private static java.lang.String |
SERVICE_UNAVAILABLE_RETRY_STRATEGY_CLASS
The type of the serviceUnavailableRetryStrategy, defaults to
none . |
private static int |
SERVICE_UNAVAILABLE_RETRY_STRATEGY_MAX_RETRIES
Maximum number of retries when using a serviceUnavailableRetryStrategy.
|
private static int |
SERVICE_UNAVAILABLE_RETRY_STRATEGY_RETRY_INTERVAL
Interval in milliseconds between retries when using a serviceUnavailableRetryStrategy.
|
private static boolean |
SSL_ALLOW_ALL
If enabled, ssl hostname verifier does not check hostname.
|
private static boolean |
SSL_INSECURE
skip failure on certificate validity checks.
|
authenticationInfo, BUFFER_SEGMENT_SIZE, DEFAULT_BUFFER_SIZE, interactive, MAXIMUM_BUFFER_SIZE, MINIMUM_AMOUNT_OF_TRANSFER_CHUNKS, proxyInfo, repository, sessionEventSupport, transferEventSupport
DEFAULT_CONNECTION_TIMEOUT, DEFAULT_READ_TIMEOUT, ROLE
Constructor and Description |
---|
AbstractHttpClientWagon() |
Modifier and Type | Method and Description |
---|---|
protected int |
backoff(int wait,
java.lang.String url) |
private java.lang.String |
buildUrl(Resource resource)
Builds a complete URL string from the repository URL and the relative path of the resource passed.
|
private java.lang.String |
buildUrl(java.lang.String resourceName)
Builds a complete URL string from the repository URL and the relative path of the resource passed.
|
protected void |
cleanupGetTransfer(Resource resource) |
void |
closeConnection() |
private static org.apache.http.config.Registry<org.apache.http.auth.AuthSchemeProvider> |
createAuthSchemeRegistry() |
private static org.apache.http.impl.client.CloseableHttpClient |
createClient() |
private static org.apache.http.impl.conn.PoolingHttpClientConnectionManager |
createConnManager() |
private static org.apache.http.client.HttpRequestRetryHandler |
createRetryHandler() |
private static org.apache.http.client.ServiceUnavailableRetryStrategy |
createServiceUnavailableRetryStrategy() |
protected org.apache.http.client.methods.CloseableHttpResponse |
execute(org.apache.http.client.methods.HttpUriRequest httpMethod) |
void |
fillInputData(InputData inputData) |
private void |
fillInputData(int wait,
InputData inputData) |
void |
fillOutputData(OutputData outputData) |
protected org.apache.http.client.AuthCache |
getAuthCache() |
BasicAuthScope |
getBasicAuthScope()
Get the override values for standard HttpClient AuthScope
|
protected org.apache.http.client.CredentialsProvider |
getCredentialsProvider() |
static org.apache.http.impl.client.CloseableHttpClient |
getHttpClient() |
HttpConfiguration |
getHttpConfiguration() |
java.util.Properties |
getHttpHeaders() |
int |
getInitialBackoffSeconds() |
static int |
getMaxBackoffWaitSeconds() |
private static java.util.Collection<java.lang.Class<? extends java.io.IOException>> |
getNonRetryableExceptions() |
BasicAuthScope |
getProxyBasicAuthScope()
Get the override values for proxy HttpClient AuthScope
|
protected java.lang.String |
getURL(Repository repository)
getUrl
Implementors can override this to remove unwanted parts of the url such as role-hints
|
protected java.lang.String |
getUserAgent(org.apache.http.client.methods.HttpUriRequest method) |
protected void |
mkdirs(java.lang.String dirname) |
void |
openConnectionInternal() |
void |
put(java.io.File source,
java.lang.String resourceName)
Copy a file from local system to remote
|
private void |
put(java.io.InputStream stream,
Resource resource,
java.io.File source) |
private void |
put(int wait,
Resource resource,
java.io.File source,
org.apache.http.HttpEntity httpEntity,
java.lang.String url) |
private void |
put(Resource resource,
java.io.File source,
org.apache.http.HttpEntity httpEntity) |
private void |
put(Resource resource,
java.io.File source,
org.apache.http.HttpEntity httpEntity,
java.lang.String url) |
protected void |
putFromStream(java.io.InputStream stream,
Resource resource) |
void |
putFromStream(java.io.InputStream stream,
java.lang.String destination) |
void |
putFromStream(java.io.InputStream stream,
java.lang.String destination,
long contentLength,
long lastModified)
Copy from a local input stream to remote.
|
private boolean |
resourceExists(int wait,
java.lang.String resourceName) |
boolean |
resourceExists(java.lang.String resourceName)
Check if a remote resource exists
|
void |
setBasicAuthScope(BasicAuthScope basicAuth)
Set the override values for standard HttpClient AuthScope
|
void |
setHeaders(org.apache.http.client.methods.HttpUriRequest method) |
void |
setHttpConfiguration(HttpConfiguration httpConfiguration) |
void |
setHttpHeaders(java.util.Properties httpHeaders) |
void |
setInitialBackoffSeconds(int initialBackoffSeconds) |
static void |
setPersistentPool(boolean persistent) |
static void |
setPoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager poolingHttpClientConnectionManager) |
void |
setProxyBasicAuthScope(BasicAuthScope proxyAuth)
Set the override values for proxy HttpClient AuthScope
|
checkInputStream, checkOutputStream, get, getIfNewer, getIfNewerToStream, getInputStream, getOutputStream, getToStream
addSessionListener, addTransferListener, cleanupPutTransfer, connect, connect, connect, connect, connect, connect, createParentDirectories, disconnect, finishGetTransfer, finishPutTransfer, fireGetCompleted, fireGetInitiated, fireGetStarted, firePutCompleted, firePutInitiated, firePutStarted, fireSessionConnectionRefused, fireSessionDebug, fireSessionDisconnected, fireSessionDisconnecting, fireSessionError, fireSessionLoggedIn, fireSessionLoggedOff, fireSessionOpened, fireSessionOpening, fireTransferDebug, fireTransferError, fireTransferProgress, getAuthenticationInfo, getBufferCapacityForTransfer, getFileList, getPath, getPermissionsOverride, getProxyInfo, getProxyInfo, getReadTimeout, getRepository, getSessionEventSupport, getTimeout, getTransfer, getTransfer, getTransfer, getTransfer, getTransfer, getTransfer, getTransferEventSupport, hasSessionListener, hasTransferListener, isInteractive, openConnection, postProcessListeners, putDirectory, putTransfer, putTransfer, removeSessionListener, removeTransferListener, setInteractive, setPermissionsOverride, setReadTimeout, setSessionEventSupport, setTimeout, setTransferEventSupport, supportsDirectoryCopy, transfer, transfer, transfer, transfer
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addSessionListener, addTransferListener, connect, connect, connect, connect, connect, connect, disconnect, getFileList, getReadTimeout, getRepository, getTimeout, hasSessionListener, hasTransferListener, isInteractive, openConnection, putDirectory, removeSessionListener, removeTransferListener, setInteractive, setReadTimeout, setTimeout, supportsDirectoryCopy
private static final java.util.TimeZone GMT_TIME_ZONE
private static boolean persistentPool
private static final boolean SSL_INSECURE
private static final boolean IGNORE_SSL_VALIDITY_DATES
private static final boolean SSL_ALLOW_ALL
private static final int MAX_CONN_PER_ROUTE
private static final int MAX_CONN_TOTAL
private static final long CONN_TTL
private static org.apache.http.conn.HttpClientConnectionManager httpClientConnectionManager
protected static final int SC_TOO_MANY_REQUESTS
private int initialBackoffSeconds
private static final int MAX_BACKOFF_WAIT_SECONDS
private static final java.lang.String RETRY_HANDLER_CLASS
standard
.
Values can be DefaultHttpRequestRetryHandler
,
or StandardHttpRequestRetryHandler
,
or a fully qualified name class with a no-arg.private static final boolean RETRY_HANDLER_REQUEST_SENT_ENABLED
false
.
Note: only used for default and standard retry handlers.private static final int RETRY_HANDLER_COUNT
private static final java.lang.String RETRY_HANDLER_EXCEPTIONS
private static final java.lang.String SERVICE_UNAVAILABLE_RETRY_STRATEGY_CLASS
none
.
Values can be DefaultServiceUnavailableRetryStrategy
,
or StandardServiceUnavailableRetryStrategy
, or
a fully qualified name class with a no-arg or none to not use a ServiceUnavailableRetryStrategy.private static final int SERVICE_UNAVAILABLE_RETRY_STRATEGY_RETRY_INTERVAL
private static final int SERVICE_UNAVAILABLE_RETRY_STRATEGY_MAX_RETRIES
private static org.apache.http.impl.client.CloseableHttpClient httpClient
private org.apache.http.client.CredentialsProvider credentialsProvider
private org.apache.http.client.AuthCache authCache
private java.io.Closeable closeable
private java.util.Properties httpHeaders
private HttpConfiguration httpConfiguration
private BasicAuthScope basicAuth
private BasicAuthScope proxyAuth
protected int backoff(int wait, java.lang.String url) throws java.lang.InterruptedException, TransferFailedException
java.lang.InterruptedException
TransferFailedException
private static org.apache.http.impl.conn.PoolingHttpClientConnectionManager createConnManager()
private static org.apache.http.client.HttpRequestRetryHandler createRetryHandler()
private static org.apache.http.client.ServiceUnavailableRetryStrategy createServiceUnavailableRetryStrategy()
private static org.apache.http.config.Registry<org.apache.http.auth.AuthSchemeProvider> createAuthSchemeRegistry()
private static java.util.Collection<java.lang.Class<? extends java.io.IOException>> getNonRetryableExceptions()
private static org.apache.http.impl.client.CloseableHttpClient createClient()
public void openConnectionInternal()
openConnectionInternal
in class AbstractWagon
public void closeConnection()
closeConnection
in class StreamWagon
public static org.apache.http.impl.client.CloseableHttpClient getHttpClient()
public static void setPersistentPool(boolean persistent)
public static void setPoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager poolingHttpClientConnectionManager)
public void put(java.io.File source, java.lang.String resourceName) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
Wagon
put
in interface Wagon
put
in class StreamWagon
source
- the local fileresourceName
- the remote destinationTransferFailedException
ResourceDoesNotExistException
AuthorizationException
public void putFromStream(java.io.InputStream stream, java.lang.String destination, long contentLength, long lastModified) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
StreamingWagon
putFromStream
in interface StreamingWagon
putFromStream
in class StreamWagon
stream
- the local streamdestination
- the remote destinationTransferFailedException
ResourceDoesNotExistException
AuthorizationException
private void put(java.io.InputStream stream, Resource resource, java.io.File source) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
private void put(Resource resource, java.io.File source, org.apache.http.HttpEntity httpEntity) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
private java.lang.String buildUrl(Resource resource)
resource
- the resource to extract the relative path from.private java.lang.String buildUrl(java.lang.String resourceName)
resourceName
- the resourcerelative pathprivate void put(Resource resource, java.io.File source, org.apache.http.HttpEntity httpEntity, java.lang.String url) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
private void put(int wait, Resource resource, java.io.File source, org.apache.http.HttpEntity httpEntity, java.lang.String url) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
protected void mkdirs(java.lang.String dirname) throws org.apache.http.HttpException, java.io.IOException
org.apache.http.HttpException
java.io.IOException
public boolean resourceExists(java.lang.String resourceName) throws TransferFailedException, AuthorizationException
Wagon
resourceExists
in interface Wagon
resourceExists
in class AbstractWagon
TransferFailedException
- if there's an error trying to access the remote sideAuthorizationException
- if not authorized to verify the existence of the resourceprivate boolean resourceExists(int wait, java.lang.String resourceName) throws TransferFailedException, AuthorizationException
protected org.apache.http.client.methods.CloseableHttpResponse execute(org.apache.http.client.methods.HttpUriRequest httpMethod) throws org.apache.http.HttpException, java.io.IOException
org.apache.http.HttpException
java.io.IOException
public void setHeaders(org.apache.http.client.methods.HttpUriRequest method)
protected java.lang.String getUserAgent(org.apache.http.client.methods.HttpUriRequest method)
protected java.lang.String getURL(Repository repository)
repository
- public HttpConfiguration getHttpConfiguration()
public void setHttpConfiguration(HttpConfiguration httpConfiguration)
public BasicAuthScope getBasicAuthScope()
public void setBasicAuthScope(BasicAuthScope basicAuth)
basicAuth
- the AuthScope to setpublic BasicAuthScope getProxyBasicAuthScope()
public void setProxyBasicAuthScope(BasicAuthScope proxyAuth)
proxyAuth
- the AuthScope to setpublic void fillInputData(InputData inputData) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
fillInputData
in class StreamWagon
TransferFailedException
ResourceDoesNotExistException
AuthorizationException
private void fillInputData(int wait, InputData inputData) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
protected void cleanupGetTransfer(Resource resource)
cleanupGetTransfer
in class AbstractWagon
public void putFromStream(java.io.InputStream stream, java.lang.String destination) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
putFromStream
in interface StreamingWagon
putFromStream
in class StreamWagon
stream
- the local streamdestination
- the remote destinationTransferFailedException
ResourceDoesNotExistException
AuthorizationException
protected void putFromStream(java.io.InputStream stream, Resource resource) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
putFromStream
in class StreamWagon
TransferFailedException
AuthorizationException
ResourceDoesNotExistException
public java.util.Properties getHttpHeaders()
public void setHttpHeaders(java.util.Properties httpHeaders)
public void fillOutputData(OutputData outputData) throws TransferFailedException
fillOutputData
in class StreamWagon
TransferFailedException
protected org.apache.http.client.CredentialsProvider getCredentialsProvider()
protected org.apache.http.client.AuthCache getAuthCache()
public int getInitialBackoffSeconds()
public void setInitialBackoffSeconds(int initialBackoffSeconds)
public static int getMaxBackoffWaitSeconds()