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 classHttpTransporter.EntityGetterprivate classHttpTransporter.PutTaskEntity
-
Field Summary
Fields Modifier and Type Field Description private java.net.URIbaseUriprivate org.apache.http.client.HttpClientclientprivate static java.util.regex.PatternCONTENT_RANGE_PATTERNprivate java.util.Map<?,?>headersprivate static org.slf4j.LoggerLOGGERprivate org.apache.http.HttpHostproxyprivate AuthenticationContextproxyAuthContextprivate AuthenticationContextrepoAuthContextprivate org.apache.http.HttpHostserverprivate LocalStatestate-
Fields inherited from interface org.eclipse.aether.spi.connector.transport.Transporter
ERROR_NOT_FOUND, ERROR_OTHER
-
-
Constructor Summary
Constructors Constructor Description HttpTransporter(RemoteRepository repository, RepositorySystemSession session)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intclassify(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 static voidconfigureClient(org.apache.http.params.HttpParams params, RepositorySystemSession session, RemoteRepository repository, org.apache.http.HttpHost proxy)private <T extends org.apache.http.HttpEntityEnclosingRequest>
Tentity(T request, org.apache.http.HttpEntity entity)private voidexecute(org.apache.http.client.methods.HttpUriRequest request, HttpTransporter.EntityGetter getter)(package private) LocalStategetState()private voidhandleStatus(org.apache.http.HttpResponse response)protected voidimplClose()ImplementsAbstractTransporter.close(), gets only called if the transporter has not already been closed.protected voidimplGet(GetTask task)ImplementsAbstractTransporter.get(GetTask), gets only called if the transporter has not been closed.protected voidimplPeek(PeekTask task)ImplementsAbstractTransporter.peek(PeekTask), gets only called if the transporter has not been closed.protected voidimplPut(PutTask task)ImplementsAbstractTransporter.put(PutTask), gets only called if the transporter has not been closed.private booleanisPayloadPresent(org.apache.http.client.methods.HttpUriRequest request)private booleanisWebDav(org.apache.http.HttpResponse response)private voidmkdirs(java.net.URI uri, SharingHttpContext context)private voidprepare(org.apache.http.client.methods.HttpUriRequest request, SharingHttpContext context)private java.net.URIresolve(TransportTask task)private <T extends org.apache.http.client.methods.HttpUriRequest>
Tresume(T request, GetTask task)private static org.apache.http.client.CredentialsProvidertoCredentialsProvider(java.lang.String host, int port, AuthenticationContext ctx)private static org.apache.http.client.CredentialsProvidertoCredentialsProvider(org.apache.http.HttpHost server, AuthenticationContext serverAuthCtx, org.apache.http.HttpHost proxy, AuthenticationContext proxyAuthCtx)private static org.apache.http.HttpHosttoHost(Proxy proxy)
-
-
-
Field Detail
-
CONTENT_RANGE_PATTERN
private static final java.util.regex.Pattern CONTENT_RANGE_PATTERN
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
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.client.HttpClient client
-
headers
private final java.util.Map<?,?> headers
-
state
private final LocalState state
-
-
Constructor Detail
-
HttpTransporter
HttpTransporter(RemoteRepository repository, RepositorySystemSession session) throws NoTransporterException
- Throws:
NoTransporterException
-
-
Method Detail
-
toHost
private static org.apache.http.HttpHost toHost(Proxy proxy)
-
configureClient
private static void configureClient(org.apache.http.params.HttpParams params, RepositorySystemSession session, RemoteRepository repository, org.apache.http.HttpHost 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:TransporterClassifies 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_FOUNDorTransporter.ERROR_OTHER.
-
implPeek
protected void implPeek(PeekTask task) throws java.lang.Exception
Description copied from class:AbstractTransporterImplementsAbstractTransporter.peek(PeekTask), gets only called if the transporter has not been closed.- Specified by:
implPeekin 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:AbstractTransporterImplementsAbstractTransporter.get(GetTask), gets only called if the transporter has not been closed.- Specified by:
implGetin 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:AbstractTransporterImplementsAbstractTransporter.put(PutTask), gets only called if the transporter has not been closed.- Specified by:
implPutin 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)
-
isWebDav
private boolean isWebDav(org.apache.http.HttpResponse response)
-
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.HttpResponse response) throws org.apache.http.client.HttpResponseException- Throws:
org.apache.http.client.HttpResponseException
-
implClose
protected void implClose()
Description copied from class:AbstractTransporterImplementsAbstractTransporter.close(), gets only called if the transporter has not already been closed.- Specified by:
implClosein classAbstractTransporter
-
-