Class Apache5HttpClient
java.lang.Object
software.amazon.awssdk.http.apache5.Apache5HttpClient
- All Implemented Interfaces:
AutoCloseable,SdkHttpClient,SdkAutoCloseable
An implementation of
SdkHttpClient that uses Apache HttpClient 5.x to communicate with the service. This is a
full-featured synchronous client that adds an extra dependency and higher startup latency compared to
UrlConnectionHttpClient
in exchange for more functionality, like support for HTTP proxies.
This client uses Apache HttpClient 5.x, which provides the following improvements over the Apache HttpClient 4.5.x based client:
- Modern Java ecosystem compatibility including virtual thread support for Java 21
- Active maintenance with regular security updates
- Enhanced logging flexibility through SLF4J (replacing problematic JCL dependencies)
Note: Performance characteristics between Apache 4.5.x and 5.x clients are similar.
See UrlConnectionHttpClient for a lighter-weight alternative implementation.
This can be created via builder()
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceBuilder for creating an instance ofSdkHttpClient. -
Method Summary
Modifier and TypeMethodDescriptionstatic Apache5HttpClient.Builderbuilder()Each HTTP client implementation should return a well-formed client name that allows requests to be identifiable back to the client that made the request.voidclose()static SdkHttpClientcreate()Create aApache5HttpClientwith the default propertiesprepareRequest(HttpExecuteRequest request) Create aExecutableHttpRequestthat can be used to execute the HTTP request.
-
Method Details
-
builder
-
create
Create aApache5HttpClientwith the default properties- Returns:
- an
Apache5HttpClient
-
prepareRequest
Description copied from interface:SdkHttpClientCreate aExecutableHttpRequestthat can be used to execute the HTTP request.- Specified by:
prepareRequestin interfaceSdkHttpClient- Parameters:
request- Representation of an HTTP request.- Returns:
- Task that can execute an HTTP request and can be aborted.
-
close
public void close()Description copied from interface:SdkAutoCloseable- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSdkAutoCloseable
-
clientName
Description copied from interface:SdkHttpClientEach HTTP client implementation should return a well-formed client name that allows requests to be identifiable back to the client that made the request. The client name should include the backing implementation as well as the Sync or Async to identify the transmission type of the request. Client names should only include alphanumeric characters. Examples of well formed client names include, ApacheSync, for requests using Apache's synchronous http client or NettyNioAsync for Netty's asynchronous http client.- Specified by:
clientNamein interfaceSdkHttpClient- Returns:
- String containing the name of the client
-