Class UrlConnectionHttpClient
java.lang.Object
software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient
- All Implemented Interfaces:
AutoCloseable
,SdkHttpClient
,SdkAutoCloseable
An implementation of
SdkHttpClient
that uses HttpURLConnection
to communicate with the service. This is the
leanest synchronous client that optimizes for minimum dependencies and startup latency in exchange for having less
functionality than other implementations.
See software.amazon.awssdk.http.apache.ApacheHttpClient for an alternative implementation.
This can be created via builder()
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A builder for an instance ofSdkHttpClient
that uses JDKs build-inURLConnection
HTTP implementation. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
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.void
close()
static SdkHttpClient
create()
Create aHttpURLConnection
client with the default propertiesstatic SdkHttpClient
create
(UrlConnectionFactory connectionFactory) Use this method if you want to control the way aHttpURLConnection
is created.prepareRequest
(HttpExecuteRequest request) Create aExecutableHttpRequest
that can be used to execute the HTTP request.
-
Method Details
-
builder
-
create
Create aHttpURLConnection
client with the default properties- Returns:
- an
UrlConnectionHttpClient
-
create
Use this method if you want to control the way aHttpURLConnection
is created. This will ignore SDK defaults likeSdkHttpConfigurationOption.CONNECTION_TIMEOUT
andSdkHttpConfigurationOption.READ_TIMEOUT
- Parameters:
connectionFactory
- a function that, given aURI
will create anHttpURLConnection
- Returns:
- an
UrlConnectionHttpClient
-
prepareRequest
Description copied from interface:SdkHttpClient
Create aExecutableHttpRequest
that can be used to execute the HTTP request.- Specified by:
prepareRequest
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSdkAutoCloseable
-
clientName
Description copied from interface:SdkHttpClient
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. 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:
clientName
in interfaceSdkHttpClient
- Returns:
- String containing the name of the client
-