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 private classAbstractHttpClientWagon.RequestEntityImplementation
-
Field Summary
Fields Modifier and Type Field Description private org.apache.http.client.AuthCacheauthCacheprivate BasicAuthScopebasicAuthBasic auth scope overridesprivate java.io.Closeablecloseableprivate static longCONN_TTLTime to live in seconds for an HTTP connection.private org.apache.http.client.CredentialsProvidercredentialsProviderprivate static java.util.TimeZoneGMT_TIME_ZONEprivate static org.apache.http.impl.client.CloseableHttpClienthttpClientprivate static org.apache.http.conn.HttpClientConnectionManagerhttpClientConnectionManagerInternal connection managerprivate HttpConfigurationhttpConfigurationprivate java.util.PropertieshttpHeadersDeprecated.Use httpConfiguration instead.private static booleanIGNORE_SSL_VALIDITY_DATESif using sslInsecure, certificate date issues will be ignored disabled by defaultprivate intinitialBackoffSecondsInitial seconds to back off when a HTTP 429 received.private static intMAX_BACKOFF_WAIT_SECONDSThe maximum amount of time we want to back off in the case of repeated HTTP 429 response codes.private static intMAX_CONN_PER_ROUTEMaximum concurrent connections per distinct route.private static intMAX_CONN_TOTALMaximum concurrent connections in total.private static booleanpersistentPooluse http(s) connection pool mechanism.private BasicAuthScopeproxyAuthProxy basic auth scope overridesprivate static java.lang.StringRETRY_HANDLER_CLASSThe type of the retry handler, defaults tostandard.private static intRETRY_HANDLER_COUNTNumber of retries for the retry handler, defaults to 3.private static java.lang.StringRETRY_HANDLER_EXCEPTIONSComma-separated list of non-retryable exception classes.private static booleanRETRY_HANDLER_REQUEST_SENT_ENABLEDWhether or not methods that have successfully sent their request will be retried, defaults tofalse.protected static intSC_TOO_MANY_REQUESTSSee RFC6585private static booleanSSL_ALLOW_ALLIf enabled, ssl hostname verifier does not check hostname.private static booleanSSL_INSECUREskip 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 intbackoff(int wait, java.lang.String url)private java.lang.StringbuildUrl(Resource resource)Builds a complete URL string from the repository URL and the relative path of the resource passed.protected java.lang.StringcalculateRelocatedUrl(org.apache.http.HttpResponse response)protected voidcleanupGetTransfer(Resource resource)voidcloseConnection()private static org.apache.http.config.Registry<org.apache.http.auth.AuthSchemeProvider>createAuthSchemeRegistry()private static org.apache.http.impl.client.CloseableHttpClientcreateClient()private static org.apache.http.impl.conn.PoolingHttpClientConnectionManagercreateConnManager()private static org.apache.http.client.HttpRequestRetryHandlercreateRetryHandler()protected org.apache.http.client.methods.CloseableHttpResponseexecute(org.apache.http.client.methods.HttpUriRequest httpMethod)private voidfillInputData(int wait, InputData inputData)voidfillInputData(InputData inputData)voidfillOutputData(OutputData outputData)protected org.apache.http.client.AuthCachegetAuthCache()BasicAuthScopegetBasicAuthScope()Get the override values for standard HttpClient AuthScopeprotected org.apache.http.client.CredentialsProvidergetCredentialsProvider()static org.apache.http.impl.client.CloseableHttpClientgetHttpClient()HttpConfigurationgetHttpConfiguration()java.util.PropertiesgetHttpHeaders()intgetInitialBackoffSeconds()static intgetMaxBackoffWaitSeconds()private static java.util.Collection<java.lang.Class<? extends java.io.IOException>>getNonRetryableExceptions()BasicAuthScopegetProxyBasicAuthScope()Get the override values for proxy HttpClient AuthScopeprotected java.lang.StringgetURL(Repository repository)getUrl Implementors can override this to remove unwanted parts of the url such as role-hintsprotected java.lang.StringgetUserAgent(org.apache.http.client.methods.HttpUriRequest method)protected voidmkdirs(java.lang.String dirname)voidopenConnectionInternal()private voidput(int wait, Resource resource, java.io.File source, org.apache.http.HttpEntity httpEntity, java.lang.String url)voidput(java.io.File source, java.lang.String resourceName)Copy a file from local system to remoteprivate voidput(java.io.InputStream stream, Resource resource, java.io.File source)private voidput(Resource resource, java.io.File source, org.apache.http.HttpEntity httpEntity)private voidput(Resource resource, java.io.File source, org.apache.http.HttpEntity httpEntity, java.lang.String url)voidputFromStream(java.io.InputStream stream, java.lang.String destination)voidputFromStream(java.io.InputStream stream, java.lang.String destination, long contentLength, long lastModified)Copy from a local input stream to remote.protected voidputFromStream(java.io.InputStream stream, Resource resource)private booleanresourceExists(int wait, java.lang.String resourceName)booleanresourceExists(java.lang.String resourceName)Check if a remote resource existsvoidsetBasicAuthScope(BasicAuthScope basicAuth)Set the override values for standard HttpClient AuthScopevoidsetHeaders(org.apache.http.client.methods.HttpUriRequest method)voidsetHttpConfiguration(HttpConfiguration httpConfiguration)voidsetHttpHeaders(java.util.Properties httpHeaders)voidsetInitialBackoffSeconds(int initialBackoffSeconds)static voidsetPersistentPool(boolean persistentPool)static voidsetPoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager poolingHttpClientConnectionManager)voidsetProxyBasicAuthScope(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
-
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.InterruptedExceptionTransferFailedException
-
createConnManager
private static org.apache.http.impl.conn.PoolingHttpClientConnectionManager createConnManager()
-
createRetryHandler
private static org.apache.http.client.HttpRequestRetryHandler createRetryHandler()
-
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:
openConnectionInternalin classAbstractWagon
-
closeConnection
public void closeConnection()
- Specified by:
closeConnectionin 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, AuthorizationExceptionDescription copied from interface:WagonCopy a file from local system to remote- Specified by:
putin interfaceWagon- Overrides:
putin classStreamWagon- Parameters:
source- the local fileresourceName- the remote destination- Throws:
TransferFailedExceptionResourceDoesNotExistExceptionAuthorizationException
-
putFromStream
public void putFromStream(java.io.InputStream stream, java.lang.String destination, long contentLength, long lastModified) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationExceptionDescription copied from interface:StreamingWagonCopy from a local input stream to remote.- Specified by:
putFromStreamin interfaceStreamingWagon- Overrides:
putFromStreamin classStreamWagon- Parameters:
stream- the local streamdestination- the remote destination- Throws:
TransferFailedExceptionResourceDoesNotExistExceptionAuthorizationException
-
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
-
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
-
calculateRelocatedUrl
protected java.lang.String calculateRelocatedUrl(org.apache.http.HttpResponse response)
-
mkdirs
protected void mkdirs(java.lang.String dirname) throws org.apache.http.HttpException, java.io.IOException- Throws:
org.apache.http.HttpExceptionjava.io.IOException
-
resourceExists
public boolean resourceExists(java.lang.String resourceName) throws TransferFailedException, AuthorizationExceptionDescription copied from interface:WagonCheck if a remote resource exists- Specified by:
resourceExistsin interfaceWagon- Overrides:
resourceExistsin 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.HttpExceptionjava.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:
fillInputDatain classStreamWagon- Throws:
TransferFailedExceptionResourceDoesNotExistExceptionAuthorizationException
-
fillInputData
private void fillInputData(int wait, InputData inputData) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
-
cleanupGetTransfer
protected void cleanupGetTransfer(Resource resource)
- Overrides:
cleanupGetTransferin classAbstractWagon
-
putFromStream
public void putFromStream(java.io.InputStream stream, java.lang.String destination) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException- Specified by:
putFromStreamin interfaceStreamingWagon- Overrides:
putFromStreamin classStreamWagon- Parameters:
stream- the local streamdestination- the remote destination- Throws:
TransferFailedExceptionResourceDoesNotExistExceptionAuthorizationException
-
putFromStream
protected void putFromStream(java.io.InputStream stream, Resource resource) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException- Overrides:
putFromStreamin classStreamWagon- Throws:
TransferFailedExceptionAuthorizationExceptionResourceDoesNotExistException
-
getHttpHeaders
public java.util.Properties getHttpHeaders()
-
setHttpHeaders
public void setHttpHeaders(java.util.Properties httpHeaders)
-
fillOutputData
public void fillOutputData(OutputData outputData) throws TransferFailedException
- Specified by:
fillOutputDatain 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()
-
-