HTTP client implementation using Java's URLConnection for the AWS SDK for Java 2.0
npx @tessl/cli install tessl/maven-software-amazon-awssdk--url-connection-client@2.33.00
# AWS SDK Java URL Connection HTTP Client
1
2
The AWS SDK Java URL Connection HTTP Client provides a synchronous HTTP client implementation using Java's built-in URLConnection class. This is the leanest synchronous client that optimizes for minimum dependencies and startup latency, making it ideal for simple applications, testing environments, or when you need to avoid additional HTTP client dependencies.
3
4
## Package Information
5
6
- **Package Name**: url-connection-client
7
- **Group ID**: software.amazon.awssdk
8
- **Package Type**: Maven
9
- **Language**: Java
10
- **Installation**: Add dependency to your Maven `pom.xml`:
11
12
```xml
13
<dependency>
14
<groupId>software.amazon.awssdk</groupId>
15
<artifactId>url-connection-client</artifactId>
16
<version>2.33.4</version>
17
</dependency>
18
```
19
20
Or for Gradle `build.gradle`:
21
22
```gradle
23
implementation 'software.amazon.awssdk:url-connection-client:2.33.4'
24
```
25
26
## Core Imports
27
28
```java
29
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
30
import software.amazon.awssdk.http.urlconnection.ProxyConfiguration;
31
import software.amazon.awssdk.http.urlconnection.UrlConnectionFactory;
32
import software.amazon.awssdk.http.urlconnection.UrlConnectionSdkHttpService;
33
import software.amazon.awssdk.http.SdkHttpClient;
34
```
35
36
## Basic Usage
37
38
```java
39
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
40
import software.amazon.awssdk.http.SdkHttpClient;
41
import java.time.Duration;
42
43
// Create a basic HTTP client with default settings
44
SdkHttpClient httpClient = UrlConnectionHttpClient.create();
45
46
// Create a configured HTTP client
47
SdkHttpClient configuredClient = UrlConnectionHttpClient.builder()
48
.connectionTimeout(Duration.ofSeconds(10))
49
.socketTimeout(Duration.ofSeconds(30))
50
.build();
51
52
// Use with AWS SDK services (the HTTP client is typically used internally by AWS service clients)
53
// Example:
54
// S3Client s3 = S3Client.builder()
55
// .httpClient(httpClient)
56
// .build();
57
```
58
59
## Architecture
60
61
The URL Connection HTTP Client is designed as a pluggable HTTP transport for the AWS SDK, implementing the standard `SdkHttpClient` interface. Key components:
62
63
- **UrlConnectionHttpClient**: Main implementation using `HttpURLConnection`
64
- **ProxyConfiguration**: Configurable HTTP proxy support with authentication
65
- **UrlConnectionFactory**: Interface for custom connection creation
66
- **Builder Pattern**: Fluent configuration of timeouts, TLS, and proxy settings
67
68
## Capabilities
69
70
### HTTP Client Creation
71
72
Create HTTP client instances with various configurations.
73
74
```java { .api }
75
// Static factory methods
76
public static SdkHttpClient create();
77
public static SdkHttpClient create(UrlConnectionFactory connectionFactory);
78
public static Builder builder();
79
```
80
81
[HTTP Client Configuration](./http-client-configuration.md)
82
83
### Proxy Configuration
84
85
Configure HTTP proxy settings with authentication and bypass rules.
86
87
```java { .api }
88
public final class ProxyConfiguration {
89
public static Builder builder();
90
public String host();
91
public int port();
92
public String scheme();
93
public String username();
94
public String password();
95
public Set<String> nonProxyHosts();
96
}
97
```
98
99
[Proxy Configuration](./proxy-configuration.md)
100
101
### Service Discovery
102
103
Auto-discovery through Java ServiceLoader mechanism for AWS SDK integration.
104
105
```java { .api }
106
public class UrlConnectionSdkHttpService implements SdkHttpService {
107
public SdkHttpClient.Builder createHttpClientBuilder();
108
}
109
```
110
111
[Service Integration](./service-integration.md)
112
113
## Types
114
115
```java { .api }
116
// Main HTTP client interface (from AWS SDK Core)
117
public interface SdkHttpClient extends Closeable {
118
ExecutableHttpRequest prepareRequest(HttpExecuteRequest request);
119
String clientName();
120
void close();
121
122
interface Builder<B extends Builder<B>> {
123
SdkHttpClient buildWithDefaults(AttributeMap serviceDefaults);
124
}
125
}
126
127
// Connection factory interface for custom connection creation
128
@FunctionalInterface
129
public interface UrlConnectionFactory {
130
HttpURLConnection createConnection(URI uri);
131
}
132
133
// Service discovery interface
134
public interface SdkHttpService {
135
SdkHttpClient.Builder createHttpClientBuilder();
136
}
137
```