@@ -77,8 +77,9 @@ final class S3ClientSettings {
77
77
key -> new Setting <>(key , "" , s -> s .toLowerCase (Locale .ROOT ), Property .NodeScope )
78
78
);
79
79
80
- /** Formerly the protocol to use to connect to s3, now unused. V2 AWS SDK can infer the protocol from {@link #endpoint}. */
81
- static final Setting .AffixSetting <HttpScheme > UNUSED_PROTOCOL_SETTING = Setting .affixKeySetting (
80
+ /** The protocol to use to connect to s3, now only used if {@link #endpoint} is not a proper URI that starts with {@code http://} or
81
+ * {@code https://}. */
82
+ static final Setting .AffixSetting <HttpScheme > PROTOCOL_SETTING = Setting .affixKeySetting (
82
83
PREFIX ,
83
84
"protocol" ,
84
85
key -> new Setting <>(key , "https" , s -> HttpScheme .valueOf (s .toUpperCase (Locale .ROOT )), Property .NodeScope , Property .Deprecated )
@@ -178,6 +179,9 @@ final class S3ClientSettings {
178
179
/** Credentials to authenticate with s3. */
179
180
final AwsCredentials credentials ;
180
181
182
+ /** The scheme (HTTP or HTTPS) for talking to the endpoint, for use only if the endpoint doesn't contain an explicit scheme */
183
+ final HttpScheme protocol ;
184
+
181
185
/** The s3 endpoint the client should talk to, or empty string to use the default. */
182
186
final String endpoint ;
183
187
@@ -218,6 +222,7 @@ final class S3ClientSettings {
218
222
219
223
private S3ClientSettings (
220
224
AwsCredentials credentials ,
225
+ HttpScheme protocol ,
221
226
String endpoint ,
222
227
String proxyHost ,
223
228
int proxyPort ,
@@ -232,6 +237,7 @@ private S3ClientSettings(
232
237
String region
233
238
) {
234
239
this .credentials = credentials ;
240
+ this .protocol = protocol ;
235
241
this .endpoint = endpoint ;
236
242
this .proxyHost = proxyHost ;
237
243
this .proxyPort = proxyPort ;
@@ -258,6 +264,7 @@ S3ClientSettings refine(Settings repositorySettings) {
258
264
.put (repositorySettings )
259
265
.normalizePrefix (PREFIX + PLACEHOLDER_CLIENT + '.' )
260
266
.build ();
267
+ final HttpScheme newProtocol = getRepoSettingOrDefault (PROTOCOL_SETTING , normalizedSettings , protocol );
261
268
final String newEndpoint = getRepoSettingOrDefault (ENDPOINT_SETTING , normalizedSettings , endpoint );
262
269
263
270
final String newProxyHost = getRepoSettingOrDefault (PROXY_HOST_SETTING , normalizedSettings , proxyHost );
@@ -281,7 +288,8 @@ S3ClientSettings refine(Settings repositorySettings) {
281
288
newCredentials = credentials ;
282
289
}
283
290
final String newRegion = getRepoSettingOrDefault (REGION , normalizedSettings , region );
284
- if (Objects .equals (endpoint , newEndpoint )
291
+ if (Objects .equals (protocol , newProtocol )
292
+ && Objects .equals (endpoint , newEndpoint )
285
293
&& Objects .equals (proxyHost , newProxyHost )
286
294
&& proxyPort == newProxyPort
287
295
&& proxyScheme == newProxyScheme
@@ -296,6 +304,7 @@ S3ClientSettings refine(Settings repositorySettings) {
296
304
}
297
305
return new S3ClientSettings (
298
306
newCredentials ,
307
+ newProtocol ,
299
308
newEndpoint ,
300
309
newProxyHost ,
301
310
newProxyPort ,
@@ -402,6 +411,7 @@ static S3ClientSettings getClientSettings(final Settings settings, final String
402
411
) {
403
412
return new S3ClientSettings (
404
413
S3ClientSettings .loadCredentials (settings , clientName ),
414
+ getConfigValue (settings , clientName , PROTOCOL_SETTING ),
405
415
getConfigValue (settings , clientName , ENDPOINT_SETTING ),
406
416
getConfigValue (settings , clientName , PROXY_HOST_SETTING ),
407
417
getConfigValue (settings , clientName , PROXY_PORT_SETTING ),
@@ -432,6 +442,7 @@ public boolean equals(final Object o) {
432
442
&& maxConnections == that .maxConnections
433
443
&& maxRetries == that .maxRetries
434
444
&& Objects .equals (credentials , that .credentials )
445
+ && Objects .equals (protocol , that .protocol )
435
446
&& Objects .equals (endpoint , that .endpoint )
436
447
&& Objects .equals (proxyHost , that .proxyHost )
437
448
&& proxyScheme == that .proxyScheme
@@ -445,6 +456,7 @@ public boolean equals(final Object o) {
445
456
public int hashCode () {
446
457
return Objects .hash (
447
458
credentials ,
459
+ protocol ,
448
460
endpoint ,
449
461
proxyHost ,
450
462
proxyPort ,
0 commit comments