Class HttpTransporter
- java.lang.Object
-
- org.eclipse.aether.spi.connector.transport.AbstractTransporter
-
- org.eclipse.aether.transport.http.HttpTransporter
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,Transporter
final class HttpTransporter extends AbstractTransporter
A transporter for HTTP/HTTPS.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
HttpTransporter.EntityGetter
private class
HttpTransporter.PutTaskEntity
private static class
HttpTransporter.ResolverServiceUnavailableRetryStrategy
-
Field Summary
Fields Modifier and Type Field Description private java.net.URI
baseUri
(package private) static java.lang.String
BIND_ADDRESS
private java.util.Map<java.lang.String,ChecksumExtractor>
checksumExtractors
private org.apache.http.impl.client.CloseableHttpClient
client
private static java.util.regex.Pattern
CONTENT_RANGE_PATTERN
private java.util.Map<?,?>
headers
(package private) static java.lang.String
HTTP_RETRY_HANDLER_NAME
private static java.lang.String
HTTP_RETRY_HANDLER_NAME_DEFAULT
private static java.lang.String
HTTP_RETRY_HANDLER_NAME_STANDARD
(package private) static java.lang.String
HTTP_RETRY_HANDLER_REQUEST_SENT_ENABLED
private static org.slf4j.Logger
LOGGER
(package private) static java.lang.String
PREEMPTIVE_PUT_AUTH
private boolean
preemptiveAuth
private boolean
preemptivePutAuth
private org.apache.http.HttpHost
proxy
private AuthenticationContext
proxyAuthContext
private AuthenticationContext
repoAuthContext
private org.apache.http.HttpHost
server
private LocalState
state
(package private) static java.lang.String
SUPPORT_WEBDAV
private boolean
supportWebDav
(package private) static java.lang.String
USE_SYSTEM_PROPERTIES
-
Fields inherited from interface org.eclipse.aether.spi.connector.transport.Transporter
ERROR_NOT_FOUND, ERROR_OTHER
-
-
Constructor Summary
Constructors Constructor Description HttpTransporter(java.util.Map<java.lang.String,ChecksumExtractor> checksumExtractors, RemoteRepository repository, RepositorySystemSession session)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
classify(java.lang.Throwable error)
Classifies the type of exception that has been thrown from a previous request to the transporter.private <T extends org.apache.http.client.methods.HttpUriRequest>
TcommonHeaders(T request)
private <T extends org.apache.http.HttpEntityEnclosingRequest>
Tentity(T request, org.apache.http.HttpEntity entity)
private void
execute(org.apache.http.client.methods.HttpUriRequest request, HttpTransporter.EntityGetter getter)
private java.net.InetAddress
getBindAddress(RepositorySystemSession session, RemoteRepository repository)
Returns non-nullInetAddress
if set in configuration,null
otherwise.(package private) LocalState
getState()
private void
handleStatus(org.apache.http.client.methods.CloseableHttpResponse response)
protected void
implClose()
ImplementsAbstractTransporter.close()
, gets only called if the transporter has not already been closed.protected void
implGet(GetTask task)
ImplementsAbstractTransporter.get(GetTask)
, gets only called if the transporter has not been closed.protected void
implPeek(PeekTask task)
ImplementsAbstractTransporter.peek(PeekTask)
, gets only called if the transporter has not been closed.protected void
implPut(PutTask task)
ImplementsAbstractTransporter.put(PutTask)
, gets only called if the transporter has not been closed.private boolean
isPayloadPresent(org.apache.http.client.methods.HttpUriRequest request)
private void
mkdirs(java.net.URI uri, SharingHttpContext context)
private void
prepare(org.apache.http.client.methods.HttpUriRequest request, SharingHttpContext context)
private java.net.URI
resolve(TransportTask task)
private <T extends org.apache.http.client.methods.HttpUriRequest>
Tresume(T request, GetTask task)
private static org.apache.http.client.CredentialsProvider
toCredentialsProvider(java.lang.String host, int port, AuthenticationContext ctx)
private static org.apache.http.client.CredentialsProvider
toCredentialsProvider(org.apache.http.HttpHost server, AuthenticationContext serverAuthCtx, org.apache.http.HttpHost proxy, AuthenticationContext proxyAuthCtx)
private static org.apache.http.HttpHost
toHost(Proxy proxy)
-
-
-
Field Detail
-
BIND_ADDRESS
static final java.lang.String BIND_ADDRESS
- See Also:
- Constant Field Values
-
SUPPORT_WEBDAV
static final java.lang.String SUPPORT_WEBDAV
- See Also:
- Constant Field Values
-
PREEMPTIVE_PUT_AUTH
static final java.lang.String PREEMPTIVE_PUT_AUTH
- See Also:
- Constant Field Values
-
USE_SYSTEM_PROPERTIES
static final java.lang.String USE_SYSTEM_PROPERTIES
- See Also:
- Constant Field Values
-
HTTP_RETRY_HANDLER_NAME
static final java.lang.String HTTP_RETRY_HANDLER_NAME
- See Also:
- Constant Field Values
-
HTTP_RETRY_HANDLER_NAME_STANDARD
private static final java.lang.String HTTP_RETRY_HANDLER_NAME_STANDARD
- See Also:
- Constant Field Values
-
HTTP_RETRY_HANDLER_NAME_DEFAULT
private static final java.lang.String HTTP_RETRY_HANDLER_NAME_DEFAULT
- See Also:
- Constant Field Values
-
HTTP_RETRY_HANDLER_REQUEST_SENT_ENABLED
static final java.lang.String HTTP_RETRY_HANDLER_REQUEST_SENT_ENABLED
- See Also:
- Constant Field Values
-
CONTENT_RANGE_PATTERN
private static final java.util.regex.Pattern CONTENT_RANGE_PATTERN
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
checksumExtractors
private final java.util.Map<java.lang.String,ChecksumExtractor> checksumExtractors
-
repoAuthContext
private final AuthenticationContext repoAuthContext
-
proxyAuthContext
private final AuthenticationContext proxyAuthContext
-
baseUri
private final java.net.URI baseUri
-
server
private final org.apache.http.HttpHost server
-
proxy
private final org.apache.http.HttpHost proxy
-
client
private final org.apache.http.impl.client.CloseableHttpClient client
-
headers
private final java.util.Map<?,?> headers
-
state
private final LocalState state
-
preemptiveAuth
private final boolean preemptiveAuth
-
preemptivePutAuth
private final boolean preemptivePutAuth
-
supportWebDav
private final boolean supportWebDav
-
-
Constructor Detail
-
HttpTransporter
HttpTransporter(java.util.Map<java.lang.String,ChecksumExtractor> checksumExtractors, RemoteRepository repository, RepositorySystemSession session) throws NoTransporterException
- Throws:
NoTransporterException
-
-
Method Detail
-
getBindAddress
private java.net.InetAddress getBindAddress(RepositorySystemSession session, RemoteRepository repository)
Returns non-nullInetAddress
if set in configuration,null
otherwise.
-
toHost
private static org.apache.http.HttpHost toHost(Proxy proxy)
-
toCredentialsProvider
private static org.apache.http.client.CredentialsProvider toCredentialsProvider(org.apache.http.HttpHost server, AuthenticationContext serverAuthCtx, org.apache.http.HttpHost proxy, AuthenticationContext proxyAuthCtx)
-
toCredentialsProvider
private static org.apache.http.client.CredentialsProvider toCredentialsProvider(java.lang.String host, int port, AuthenticationContext ctx)
-
getState
LocalState getState()
-
resolve
private java.net.URI resolve(TransportTask task)
-
classify
public int classify(java.lang.Throwable error)
Description copied from interface:Transporter
Classifies the type of exception that has been thrown from a previous request to the transporter. The exception types employed by a transporter are generally unknown to its caller. Where a caller needs to distinguish between certain error cases, it employs this method to detect which error case corresponds to the exception.- Parameters:
error
- The exception to classify, must not benull
.- Returns:
- The classification of the error, either
Transporter.ERROR_NOT_FOUND
orTransporter.ERROR_OTHER
.
-
implPeek
protected void implPeek(PeekTask task) throws java.lang.Exception
Description copied from class:AbstractTransporter
ImplementsAbstractTransporter.peek(PeekTask)
, gets only called if the transporter has not been closed.- Specified by:
implPeek
in classAbstractTransporter
- Parameters:
task
- The existence check to perform, must not benull
.- Throws:
java.lang.Exception
- If the existence of the specified resource could not be confirmed.
-
implGet
protected void implGet(GetTask task) throws java.lang.Exception
Description copied from class:AbstractTransporter
ImplementsAbstractTransporter.get(GetTask)
, gets only called if the transporter has not been closed.- Specified by:
implGet
in classAbstractTransporter
- Parameters:
task
- The download to perform, must not benull
.- Throws:
java.lang.Exception
- If the transfer failed.
-
implPut
protected void implPut(PutTask task) throws java.lang.Exception
Description copied from class:AbstractTransporter
ImplementsAbstractTransporter.put(PutTask)
, gets only called if the transporter has not been closed.- Specified by:
implPut
in classAbstractTransporter
- Parameters:
task
- The upload to perform, must not benull
.- Throws:
java.lang.Exception
- If the transfer failed.
-
execute
private void execute(org.apache.http.client.methods.HttpUriRequest request, HttpTransporter.EntityGetter getter) throws java.lang.Exception
- Throws:
java.lang.Exception
-
prepare
private void prepare(org.apache.http.client.methods.HttpUriRequest request, SharingHttpContext context)
-
mkdirs
private void mkdirs(java.net.URI uri, SharingHttpContext context)
-
entity
private <T extends org.apache.http.HttpEntityEnclosingRequest> T entity(T request, org.apache.http.HttpEntity entity)
-
isPayloadPresent
private boolean isPayloadPresent(org.apache.http.client.methods.HttpUriRequest request)
-
commonHeaders
private <T extends org.apache.http.client.methods.HttpUriRequest> T commonHeaders(T request)
-
resume
private <T extends org.apache.http.client.methods.HttpUriRequest> T resume(T request, GetTask task)
-
handleStatus
private void handleStatus(org.apache.http.client.methods.CloseableHttpResponse response) throws org.apache.http.client.HttpResponseException
- Throws:
org.apache.http.client.HttpResponseException
-
implClose
protected void implClose()
Description copied from class:AbstractTransporter
ImplementsAbstractTransporter.close()
, gets only called if the transporter has not already been closed.- Specified by:
implClose
in classAbstractTransporter
-
-