Class AbstractHttpClientWagon
- java.lang.Object
-
- org.apache.maven.wagon.AbstractWagon
-
- org.apache.maven.wagon.StreamWagon
-
- org.apache.maven.wagon.shared.http.AbstractHttpClientWagon
-
- All Implemented Interfaces:
StreamingWagon
,Wagon
- Direct Known Subclasses:
HttpWagon
public abstract class AbstractHttpClientWagon extends StreamWagon
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
AbstractHttpClientWagon.WagonHttpEntity
-
Field Summary
Fields Modifier and Type Field Description private org.apache.http.client.AuthCache
authCache
private BasicAuthScope
basicAuth
Basic auth scope overridesprivate 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 managerprivate 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 defaultprivate 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 overridesprivate static java.lang.String
RETRY_HANDLER_CLASS
The type of the retry handler, defaults tostandard
.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 tofalse
.protected static int
SC_TOO_MANY_REQUESTS
See RFC6585private static java.lang.String
SERVICE_UNAVAILABLE_RETRY_STRATEGY_CLASS
The type of the serviceUnavailableRetryStrategy, defaults tonone
.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.-
Fields inherited from class org.apache.maven.wagon.AbstractWagon
authenticationInfo, BUFFER_SEGMENT_SIZE, DEFAULT_BUFFER_SIZE, interactive, MAXIMUM_BUFFER_SIZE, MINIMUM_AMOUNT_OF_TRANSFER_CHUNKS, proxyInfo, repository, sessionEventSupport, transferEventSupport
-
Fields inherited from interface org.apache.maven.wagon.Wagon
DEFAULT_CONNECTION_TIMEOUT, DEFAULT_READ_TIMEOUT, ROLE
-
-
Constructor Summary
Constructors Constructor Description AbstractHttpClientWagon()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
backoff(int wait, java.lang.String url)
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.private java.lang.String
buildUrl(Resource resource)
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)
private void
fillInputData(int wait, InputData inputData)
void
fillInputData(InputData inputData)
void
fillOutputData(OutputData outputData)
protected org.apache.http.client.AuthCache
getAuthCache()
BasicAuthScope
getBasicAuthScope()
Get the override values for standard HttpClient AuthScopeprotected 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 AuthScopeprotected java.lang.String
getURL(Repository repository)
getUrl Implementors can override this to remove unwanted parts of the url such as role-hintsprotected java.lang.String
getUserAgent(org.apache.http.client.methods.HttpUriRequest method)
protected void
mkdirs(java.lang.String dirname)
void
openConnectionInternal()
private void
put(int wait, Resource resource, java.io.File source, org.apache.http.HttpEntity httpEntity, java.lang.String url)
void
put(java.io.File source, java.lang.String resourceName)
Copy a file from local system to remoteprivate void
put(java.io.InputStream stream, Resource resource, java.io.File source)
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)
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.protected void
putFromStream(java.io.InputStream stream, Resource resource)
private boolean
resourceExists(int wait, java.lang.String resourceName)
boolean
resourceExists(java.lang.String resourceName)
Check if a remote resource existsvoid
setBasicAuthScope(BasicAuthScope basicAuth)
Set the override values for standard HttpClient AuthScopevoid
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 persistentPool)
static void
setPoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager poolingHttpClientConnectionManager)
void
setProxyBasicAuthScope(BasicAuthScope proxyAuth)
Set the override values for proxy HttpClient AuthScope-
Methods inherited from class org.apache.maven.wagon.StreamWagon
checkInputStream, checkOutputStream, get, getIfNewer, getIfNewerToStream, getInputStream, getOutputStream, getToStream
-
Methods inherited from class org.apache.maven.wagon.AbstractWagon
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.maven.wagon.Wagon
addSessionListener, addTransferListener, connect, connect, connect, connect, connect, connect, disconnect, getFileList, getReadTimeout, getRepository, getTimeout, hasSessionListener, hasTransferListener, isInteractive, openConnection, putDirectory, removeSessionListener, removeTransferListener, setInteractive, setReadTimeout, setTimeout, supportsDirectoryCopy
-
-
-
-
Field Detail
-
GMT_TIME_ZONE
private static final java.util.TimeZone GMT_TIME_ZONE
-
persistentPool
private static boolean persistentPool
use http(s) connection pool mechanism. enabled by default
-
SSL_INSECURE
private static final boolean SSL_INSECURE
skip failure on certificate validity checks. disabled by default
-
IGNORE_SSL_VALIDITY_DATES
private static final boolean IGNORE_SSL_VALIDITY_DATES
if using sslInsecure, certificate date issues will be ignored disabled by default
-
SSL_ALLOW_ALL
private static final boolean SSL_ALLOW_ALL
If enabled, ssl hostname verifier does not check hostname. Disable this will use a browser compat hostname verifier disabled by default
-
MAX_CONN_PER_ROUTE
private static final int MAX_CONN_PER_ROUTE
Maximum concurrent connections per distinct route. 20 by default
-
MAX_CONN_TOTAL
private static final int MAX_CONN_TOTAL
Maximum concurrent connections in total. 40 by default
-
CONN_TTL
private static final long CONN_TTL
Time to live in seconds for an HTTP connection. After that time, the connection will be dropped. Intermediates tend to drop connections after some idle period. Set to -1 to maintain connections indefinitely. This value defaults to 300 seconds.- Since:
- 3.2
-
httpClientConnectionManager
private static org.apache.http.conn.HttpClientConnectionManager httpClientConnectionManager
Internal connection manager
-
SC_TOO_MANY_REQUESTS
protected static final int SC_TOO_MANY_REQUESTS
See RFC6585- See Also:
- Constant Field Values
-
initialBackoffSeconds
private int initialBackoffSeconds
Initial seconds to back off when a HTTP 429 received. Subsequent 429 responses result in exponental backoff. 5 by default- Since:
- 2.7
-
MAX_BACKOFF_WAIT_SECONDS
private static final int MAX_BACKOFF_WAIT_SECONDS
The maximum amount of time we want to back off in the case of repeated HTTP 429 response codes.- Since:
- 2.7
-
RETRY_HANDLER_CLASS
private static final java.lang.String RETRY_HANDLER_CLASS
The type of the retry handler, defaults tostandard
. Values can be {@link default DefaultHttpRequestRetryHandler}, orStandardHttpRequestRetryHandler
, or a fully qualified name class with a no-arg.- Since:
- 3.2
-
RETRY_HANDLER_REQUEST_SENT_ENABLED
private static final boolean RETRY_HANDLER_REQUEST_SENT_ENABLED
Whether or not methods that have successfully sent their request will be retried, defaults tofalse
. Note: only used for default and standard retry handlers.- Since:
- 3.2
-
RETRY_HANDLER_COUNT
private static final int RETRY_HANDLER_COUNT
Number of retries for the retry handler, defaults to 3. Note: only used for default and standard retry handlers.- Since:
- 3.2
-
RETRY_HANDLER_EXCEPTIONS
private static final java.lang.String RETRY_HANDLER_EXCEPTIONS
Comma-separated list of non-retryable exception classes. Note: only used for default retry handler.- Since:
- 3.2
-
SERVICE_UNAVAILABLE_RETRY_STRATEGY_CLASS
private static final java.lang.String SERVICE_UNAVAILABLE_RETRY_STRATEGY_CLASS
The type of the serviceUnavailableRetryStrategy, defaults tonone
. Values can be {@link default DefaultServiceUnavailableRetryStrategy}, orStandardServiceUnavailableRetryStrategy
, or a fully qualified name class with a no-arg or none to not use a ServiceUnavailableRetryStrategy.
-
SERVICE_UNAVAILABLE_RETRY_STRATEGY_RETRY_INTERVAL
private static final int SERVICE_UNAVAILABLE_RETRY_STRATEGY_RETRY_INTERVAL
Interval in milliseconds between retries when using a serviceUnavailableRetryStrategy. 1000 by default
-
SERVICE_UNAVAILABLE_RETRY_STRATEGY_MAX_RETRIES
private static final int SERVICE_UNAVAILABLE_RETRY_STRATEGY_MAX_RETRIES
Maximum number of retries when using a serviceUnavailableRetryStrategy. 5 by default
-
httpClient
private static org.apache.http.impl.client.CloseableHttpClient httpClient
-
credentialsProvider
private org.apache.http.client.CredentialsProvider credentialsProvider
-
authCache
private org.apache.http.client.AuthCache authCache
-
closeable
private java.io.Closeable closeable
-
httpHeaders
private java.util.Properties httpHeaders
Deprecated.Use httpConfiguration instead.
-
httpConfiguration
private HttpConfiguration httpConfiguration
- Since:
- 1.0-beta-6
-
basicAuth
private BasicAuthScope basicAuth
Basic auth scope overrides- Since:
- 2.8
-
proxyAuth
private BasicAuthScope proxyAuth
Proxy basic auth scope overrides- Since:
- 2.8
-
-
Method Detail
-
backoff
protected int backoff(int wait, java.lang.String url) throws java.lang.InterruptedException, TransferFailedException
- Throws:
java.lang.InterruptedException
TransferFailedException
-
createConnManager
private static org.apache.http.impl.conn.PoolingHttpClientConnectionManager createConnManager()
-
createRetryHandler
private static org.apache.http.client.HttpRequestRetryHandler createRetryHandler()
-
createServiceUnavailableRetryStrategy
private static org.apache.http.client.ServiceUnavailableRetryStrategy createServiceUnavailableRetryStrategy()
-
createAuthSchemeRegistry
private static org.apache.http.config.Registry<org.apache.http.auth.AuthSchemeProvider> createAuthSchemeRegistry()
-
getNonRetryableExceptions
private static java.util.Collection<java.lang.Class<? extends java.io.IOException>> getNonRetryableExceptions()
-
createClient
private static org.apache.http.impl.client.CloseableHttpClient createClient()
-
openConnectionInternal
public void openConnectionInternal()
- Specified by:
openConnectionInternal
in classAbstractWagon
-
closeConnection
public void closeConnection()
- Specified by:
closeConnection
in classStreamWagon
-
getHttpClient
public static org.apache.http.impl.client.CloseableHttpClient getHttpClient()
-
setPersistentPool
public static void setPersistentPool(boolean persistentPool)
-
setPoolingHttpClientConnectionManager
public static void setPoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager poolingHttpClientConnectionManager)
-
put
public void put(java.io.File source, java.lang.String resourceName) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
Description copied from interface:Wagon
Copy a file from local system to remote- Specified by:
put
in interfaceWagon
- Overrides:
put
in classStreamWagon
- Parameters:
source
- the local fileresourceName
- the remote destination- Throws:
TransferFailedException
ResourceDoesNotExistException
AuthorizationException
-
putFromStream
public void putFromStream(java.io.InputStream stream, java.lang.String destination, long contentLength, long lastModified) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
Description copied from interface:StreamingWagon
Copy from a local input stream to remote.- Specified by:
putFromStream
in interfaceStreamingWagon
- Overrides:
putFromStream
in classStreamWagon
- Parameters:
stream
- the local streamdestination
- the remote destination- Throws:
TransferFailedException
ResourceDoesNotExistException
AuthorizationException
-
put
private void put(java.io.InputStream stream, Resource resource, java.io.File source) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
-
put
private void put(Resource resource, java.io.File source, org.apache.http.HttpEntity httpEntity) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
-
buildUrl
private java.lang.String buildUrl(Resource resource)
Builds a complete URL string from the repository URL and the relative path of the resource passed.- Parameters:
resource
- the resource to extract the relative path from.- Returns:
- the complete URL
-
buildUrl
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.- Parameters:
resourceName
- the resourcerelative path- Returns:
- the complete URL
-
put
private void put(Resource resource, java.io.File source, org.apache.http.HttpEntity httpEntity, java.lang.String url) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
-
put
private void put(int wait, Resource resource, java.io.File source, org.apache.http.HttpEntity httpEntity, java.lang.String url) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
-
mkdirs
protected void mkdirs(java.lang.String dirname) throws org.apache.http.HttpException, java.io.IOException
- Throws:
org.apache.http.HttpException
java.io.IOException
-
resourceExists
public boolean resourceExists(java.lang.String resourceName) throws TransferFailedException, AuthorizationException
Description copied from interface:Wagon
Check if a remote resource exists- Specified by:
resourceExists
in interfaceWagon
- Overrides:
resourceExists
in classAbstractWagon
- Returns:
- whether the resource exists or not
- Throws:
TransferFailedException
- if there's an error trying to access the remote sideAuthorizationException
- if not authorized to verify the existence of the resource
-
resourceExists
private boolean resourceExists(int wait, java.lang.String resourceName) throws TransferFailedException, AuthorizationException
-
execute
protected org.apache.http.client.methods.CloseableHttpResponse execute(org.apache.http.client.methods.HttpUriRequest httpMethod) throws org.apache.http.HttpException, java.io.IOException
- Throws:
org.apache.http.HttpException
java.io.IOException
-
setHeaders
public void setHeaders(org.apache.http.client.methods.HttpUriRequest method)
-
getUserAgent
protected java.lang.String getUserAgent(org.apache.http.client.methods.HttpUriRequest method)
-
getURL
protected java.lang.String getURL(Repository repository)
getUrl Implementors can override this to remove unwanted parts of the url such as role-hints- Parameters:
repository
-- Returns:
-
getHttpConfiguration
public HttpConfiguration getHttpConfiguration()
-
setHttpConfiguration
public void setHttpConfiguration(HttpConfiguration httpConfiguration)
-
getBasicAuthScope
public BasicAuthScope getBasicAuthScope()
Get the override values for standard HttpClient AuthScope- Returns:
- the basicAuth
-
setBasicAuthScope
public void setBasicAuthScope(BasicAuthScope basicAuth)
Set the override values for standard HttpClient AuthScope- Parameters:
basicAuth
- the AuthScope to set
-
getProxyBasicAuthScope
public BasicAuthScope getProxyBasicAuthScope()
Get the override values for proxy HttpClient AuthScope- Returns:
- the proxyAuth
-
setProxyBasicAuthScope
public void setProxyBasicAuthScope(BasicAuthScope proxyAuth)
Set the override values for proxy HttpClient AuthScope- Parameters:
proxyAuth
- the AuthScope to set
-
fillInputData
public void fillInputData(InputData inputData) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- Specified by:
fillInputData
in classStreamWagon
- Throws:
TransferFailedException
ResourceDoesNotExistException
AuthorizationException
-
fillInputData
private void fillInputData(int wait, InputData inputData) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
-
cleanupGetTransfer
protected void cleanupGetTransfer(Resource resource)
- Overrides:
cleanupGetTransfer
in classAbstractWagon
-
putFromStream
public void putFromStream(java.io.InputStream stream, java.lang.String destination) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- Specified by:
putFromStream
in interfaceStreamingWagon
- Overrides:
putFromStream
in classStreamWagon
- Parameters:
stream
- the local streamdestination
- the remote destination- Throws:
TransferFailedException
ResourceDoesNotExistException
AuthorizationException
-
putFromStream
protected void putFromStream(java.io.InputStream stream, Resource resource) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- Overrides:
putFromStream
in classStreamWagon
- Throws:
TransferFailedException
AuthorizationException
ResourceDoesNotExistException
-
getHttpHeaders
public java.util.Properties getHttpHeaders()
-
setHttpHeaders
public void setHttpHeaders(java.util.Properties httpHeaders)
-
fillOutputData
public void fillOutputData(OutputData outputData) throws TransferFailedException
- Specified by:
fillOutputData
in classStreamWagon
- Throws:
TransferFailedException
-
getCredentialsProvider
protected org.apache.http.client.CredentialsProvider getCredentialsProvider()
-
getAuthCache
protected org.apache.http.client.AuthCache getAuthCache()
-
getInitialBackoffSeconds
public int getInitialBackoffSeconds()
-
setInitialBackoffSeconds
public void setInitialBackoffSeconds(int initialBackoffSeconds)
-
getMaxBackoffWaitSeconds
public static int getMaxBackoffWaitSeconds()
-
-