@@ -77,9 +77,10 @@ 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}. */
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://}. */
81
82
@ UpdateForV10 (owner = UpdateForV10 .Owner .DISTRIBUTED_COORDINATION ) // no longer used, should be removed in v10
82
- static final Setting .AffixSetting <HttpScheme > UNUSED_PROTOCOL_SETTING = Setting .affixKeySetting (
83
+ static final Setting .AffixSetting <HttpScheme > PROTOCOL_SETTING = Setting .affixKeySetting (
83
84
PREFIX ,
84
85
"protocol" ,
85
86
key -> new Setting <>(key , "https" , s -> HttpScheme .valueOf (s .toUpperCase (Locale .ROOT )), Property .NodeScope , Property .Deprecated )
@@ -181,6 +182,9 @@ final class S3ClientSettings {
181
182
/** Credentials to authenticate with s3. */
182
183
final AwsCredentials credentials ;
183
184
185
+ /** The scheme (HTTP or HTTPS) for talking to the endpoint, for use only if the endpoint doesn't contain an explicit scheme */
186
+ final HttpScheme protocol ;
187
+
184
188
/** The s3 endpoint the client should talk to, or empty string to use the default. */
185
189
final String endpoint ;
186
190
@@ -221,6 +225,7 @@ final class S3ClientSettings {
221
225
222
226
private S3ClientSettings (
223
227
AwsCredentials credentials ,
228
+ HttpScheme protocol ,
224
229
String endpoint ,
225
230
String proxyHost ,
226
231
int proxyPort ,
@@ -235,6 +240,7 @@ private S3ClientSettings(
235
240
String region
236
241
) {
237
242
this .credentials = credentials ;
243
+ this .protocol = protocol ;
238
244
this .endpoint = endpoint ;
239
245
this .proxyHost = proxyHost ;
240
246
this .proxyPort = proxyPort ;
@@ -261,6 +267,7 @@ S3ClientSettings refine(Settings repositorySettings) {
261
267
.put (repositorySettings )
262
268
.normalizePrefix (PREFIX + PLACEHOLDER_CLIENT + '.' )
263
269
.build ();
270
+ final HttpScheme newProtocol = getRepoSettingOrDefault (PROTOCOL_SETTING , normalizedSettings , protocol );
264
271
final String newEndpoint = getRepoSettingOrDefault (ENDPOINT_SETTING , normalizedSettings , endpoint );
265
272
266
273
final String newProxyHost = getRepoSettingOrDefault (PROXY_HOST_SETTING , normalizedSettings , proxyHost );
@@ -284,7 +291,8 @@ S3ClientSettings refine(Settings repositorySettings) {
284
291
newCredentials = credentials ;
285
292
}
286
293
final String newRegion = getRepoSettingOrDefault (REGION , normalizedSettings , region );
287
- if (Objects .equals (endpoint , newEndpoint )
294
+ if (Objects .equals (protocol , newProtocol )
295
+ && Objects .equals (endpoint , newEndpoint )
288
296
&& Objects .equals (proxyHost , newProxyHost )
289
297
&& proxyPort == newProxyPort
290
298
&& proxyScheme == newProxyScheme
@@ -299,6 +307,7 @@ S3ClientSettings refine(Settings repositorySettings) {
299
307
}
300
308
return new S3ClientSettings (
301
309
newCredentials ,
310
+ newProtocol ,
302
311
newEndpoint ,
303
312
newProxyHost ,
304
313
newProxyPort ,
@@ -405,6 +414,7 @@ static S3ClientSettings getClientSettings(final Settings settings, final String
405
414
) {
406
415
return new S3ClientSettings (
407
416
S3ClientSettings .loadCredentials (settings , clientName ),
417
+ getConfigValue (settings , clientName , PROTOCOL_SETTING ),
408
418
getConfigValue (settings , clientName , ENDPOINT_SETTING ),
409
419
getConfigValue (settings , clientName , PROXY_HOST_SETTING ),
410
420
getConfigValue (settings , clientName , PROXY_PORT_SETTING ),
@@ -435,6 +445,7 @@ public boolean equals(final Object o) {
435
445
&& maxConnections == that .maxConnections
436
446
&& maxRetries == that .maxRetries
437
447
&& Objects .equals (credentials , that .credentials )
448
+ && Objects .equals (protocol , that .protocol )
438
449
&& Objects .equals (endpoint , that .endpoint )
439
450
&& Objects .equals (proxyHost , that .proxyHost )
440
451
&& proxyScheme == that .proxyScheme
@@ -448,6 +459,7 @@ public boolean equals(final Object o) {
448
459
public int hashCode () {
449
460
return Objects .hash (
450
461
credentials ,
462
+ protocol ,
451
463
endpoint ,
452
464
proxyHost ,
453
465
proxyPort ,
0 commit comments