Skip to content

Commit 6938be0

Browse files
committed
changed disableExpect100ContinueForPuts to expectContinueEnabled after api surface review discussions
1 parent 2f98f89 commit 6938be0

6 files changed

Lines changed: 71 additions & 68 deletions

File tree

.changes/next-release/feature-AmazonS3-7a01820.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"type": "feature",
33
"category": "Amazon S3",
44
"contributor": "",
5-
"description": "Added `disableExpect100ContinueForPuts` to `S3Configuration` to control the `Expect: 100-continue` header on PutObject and UploadPart requests. When set to `true`, the SDK stops adding the header. For Apache HTTP client users, to have `ApacheHttpClient.builder().expectContinueEnabled()` fully control the header, set `disableExpect100ContinueForPuts(true)` on `S3Configuration`."
5+
"description": "Added `expectContinueEnabled` to `S3Configuration` to control the `Expect: 100-continue` header on PutObject and UploadPart requests. When set to `false`, the SDK stops adding the header. For Apache HTTP client users, to have `ApacheHttpClient.builder().expectContinueEnabled()` fully control the header, set `expectContinueEnabled(false)` on `S3Configuration`."
66
}

services/s3/src/main/java/software/amazon/awssdk/services/s3/S3Configuration.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,17 @@ public final class S3Configuration implements ServiceConfiguration, ToCopyableBu
7272
private static final boolean DEFAULT_CHUNKED_ENCODING_ENABLED = true;
7373

7474
/**
75-
* By default, Expect: 100-continue is sent for {@link PutObjectRequest} and {@link UploadPartRequest}.
75+
* By default, the SDK sends the {@code Expect: 100-continue} header for {@link PutObjectRequest}
76+
* and {@link UploadPartRequest}.
7677
*/
77-
private static final boolean DEFAULT_DISABLE_EXPECT_100_CONTINUE_FOR_PUTS = false;
78+
private static final boolean DEFAULT_EXPECT_CONTINUE_ENABLED = true;
7879

7980
private final FieldWithDefault<Boolean> pathStyleAccessEnabled;
8081
private final FieldWithDefault<Boolean> accelerateModeEnabled;
8182
private final FieldWithDefault<Boolean> dualstackEnabled;
8283
private final FieldWithDefault<Boolean> checksumValidationEnabled;
8384
private final FieldWithDefault<Boolean> chunkedEncodingEnabled;
84-
private final FieldWithDefault<Boolean> disableExpect100ContinueForPuts;
85+
private final FieldWithDefault<Boolean> expectContinueEnabled;
8586
private final Boolean useArnRegionEnabled;
8687
private final Boolean multiRegionEnabled;
8788
private final FieldWithDefault<Supplier<ProfileFile>> profileFile;
@@ -94,8 +95,8 @@ private S3Configuration(DefaultS3ServiceConfigurationBuilder builder) {
9495
this.checksumValidationEnabled = FieldWithDefault.create(builder.checksumValidationEnabled,
9596
DEFAULT_CHECKSUM_VALIDATION_ENABLED);
9697
this.chunkedEncodingEnabled = FieldWithDefault.create(builder.chunkedEncodingEnabled, DEFAULT_CHUNKED_ENCODING_ENABLED);
97-
this.disableExpect100ContinueForPuts =
98-
FieldWithDefault.create(builder.disableExpect100ContinueForPuts, DEFAULT_DISABLE_EXPECT_100_CONTINUE_FOR_PUTS);
98+
this.expectContinueEnabled = FieldWithDefault.create(builder.expectContinueEnabled,
99+
DEFAULT_EXPECT_CONTINUE_ENABLED);
99100
this.profileFile = FieldWithDefault.create(builder.profileFile, ProfileFile::defaultProfileFile);
100101
this.profileName = FieldWithDefault.create(builder.profileName,
101102
ProfileFileSystemSetting.AWS_PROFILE.getStringValueOrThrow());
@@ -226,23 +227,23 @@ public boolean chunkedEncodingEnabled() {
226227
}
227228

228229
/**
229-
* Returns whether the S3 SDK client's explicit setting of the {@code Expect: 100-continue} header is disabled for
230+
* Returns whether the S3 SDK client's explicit setting of the {@code Expect: 100-continue} header is enabled for
230231
* {@link PutObjectRequest} and {@link UploadPartRequest}. This controls whether the SDK adds the header during
231232
* request interceptor processing.
232233
* <p>
233234
* By default, the SDK sends the {@code Expect: 100-continue} header for these operations, allowing the server to
234-
* reject the request before the client sends the full payload. Setting this to {@code true} disables this behavior.
235+
* reject the request before the client sends the full payload. Setting this to {@code false} disables this behavior.
235236
* <p>
236237
* <b>Note:</b> When using the Apache HTTP client, the Apache client also independently adds the
237238
* {@code Expect: 100-continue} header by default via its own {@code expectContinueEnabled} setting. To fully
238239
* suppress the header on the wire, you must also disable it on the Apache HTTP client builder using
239240
* {@code ApacheHttpClient.builder().expectContinueEnabled(false)}.
240241
*
241-
* @return True if the Expect: 100-continue header is disabled for put operations.
242-
* @see S3Configuration.Builder#disableExpect100ContinueForPuts(Boolean)
242+
* @return True if the Expect: 100-continue header is enabled.
243+
* @see S3Configuration.Builder#expectContinueEnabled(Boolean)
243244
*/
244-
public boolean disableExpect100ContinueForPuts() {
245-
return disableExpect100ContinueForPuts.value();
245+
public boolean expectContinueEnabled() {
246+
return expectContinueEnabled.value();
246247
}
247248

248249
/**
@@ -275,7 +276,7 @@ public Builder toBuilder() {
275276
.pathStyleAccessEnabled(pathStyleAccessEnabled.valueOrNullIfDefault())
276277
.checksumValidationEnabled(checksumValidationEnabled.valueOrNullIfDefault())
277278
.chunkedEncodingEnabled(chunkedEncodingEnabled.valueOrNullIfDefault())
278-
.disableExpect100ContinueForPuts(disableExpect100ContinueForPuts.valueOrNullIfDefault())
279+
.expectContinueEnabled(expectContinueEnabled.valueOrNullIfDefault())
279280
.useArnRegionEnabled(useArnRegionEnabled)
280281
.profileFile(profileFile.valueOrNullIfDefault())
281282
.profileName(profileName.valueOrNullIfDefault());
@@ -385,26 +386,25 @@ public interface Builder extends CopyableBuilder<Builder, S3Configuration> {
385386
*/
386387
Builder chunkedEncodingEnabled(Boolean chunkedEncodingEnabled);
387388

388-
Boolean disableExpect100ContinueForPuts();
389+
Boolean expectContinueEnabled();
389390

390391
/**
391-
* Option to disable the S3 SDK client's explicit setting of the {@code Expect: 100-continue} header for
392-
* {@link PutObjectRequest} and {@link UploadPartRequest}. This controls whether the SDK adds the header
393-
* during request interceptor processing.
392+
* Option to enable or disable the S3 SDK client's explicit setting of the {@code Expect: 100-continue} header
393+
* for {@link PutObjectRequest} and {@link UploadPartRequest}.
394394
* <p>
395395
* By default, the SDK sends the {@code Expect: 100-continue} header for these operations, allowing the server to
396-
* reject the request before the client sends the full payload. Setting this to {@code true} disables this behavior.
396+
* reject the request before the client sends the full payload. Setting this to {@code false} disables this behavior.
397397
* <p>
398398
* <b>Note:</b> When using the Apache HTTP client, the Apache client also independently adds the
399399
* {@code Expect: 100-continue} header by default via its own {@code expectContinueEnabled} setting. To fully
400400
* suppress the header on the wire, you must also disable it on the Apache HTTP client builder using
401401
* {@code ApacheHttpClient.builder().expectContinueEnabled(false)}.
402402
* <p>
403-
* Disabled by default (i.e., the header is sent).
403+
* Enabled by default (i.e., the header is sent).
404404
*
405-
* @see S3Configuration#disableExpect100ContinueForPuts()
405+
* @see S3Configuration#expectContinueEnabled()
406406
*/
407-
Builder disableExpect100ContinueForPuts(Boolean disableExpect100ContinueForPuts);
407+
Builder expectContinueEnabled(Boolean expectContinueEnabled);
408408

409409
Boolean useArnRegionEnabled();
410410

@@ -474,7 +474,7 @@ static final class DefaultS3ServiceConfigurationBuilder implements Builder {
474474
private Boolean pathStyleAccessEnabled;
475475
private Boolean checksumValidationEnabled;
476476
private Boolean chunkedEncodingEnabled;
477-
private Boolean disableExpect100ContinueForPuts;
477+
private Boolean expectContinueEnabled;
478478
private Boolean useArnRegionEnabled;
479479
private Boolean multiRegionEnabled;
480480
private Supplier<ProfileFile> profileFile;
@@ -552,22 +552,22 @@ public Builder chunkedEncodingEnabled(Boolean chunkedEncodingEnabled) {
552552
}
553553

554554
@Override
555-
public Boolean disableExpect100ContinueForPuts() {
556-
return disableExpect100ContinueForPuts;
555+
public Boolean expectContinueEnabled() {
556+
return expectContinueEnabled;
557557
}
558558

559559
public void setChunkedEncodingEnabled(Boolean chunkedEncodingEnabled) {
560560
chunkedEncodingEnabled(chunkedEncodingEnabled);
561561
}
562562

563563
@Override
564-
public Builder disableExpect100ContinueForPuts(Boolean disableExpect100ContinueForPuts) {
565-
this.disableExpect100ContinueForPuts = disableExpect100ContinueForPuts;
564+
public Builder expectContinueEnabled(Boolean expectContinueEnabled) {
565+
this.expectContinueEnabled = expectContinueEnabled;
566566
return this;
567567
}
568568

569-
public void setDisableExpect100ContinueForPuts(Boolean disableExpect100ContinueForPuts) {
570-
disableExpect100ContinueForPuts(disableExpect100ContinueForPuts);
569+
public void setExpectContinueEnabled(Boolean expectContinueEnabled) {
570+
expectContinueEnabled(expectContinueEnabled);
571571
}
572572

573573
@Override

services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/handlers/StreamingRequestInterceptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
/**
3131
* Interceptor to add an 'Expect: 100-continue' header to the HTTP Request if it represents a PUT Object or Upload Part
32-
* request. This behavior can be disabled via {@link S3Configuration#disableExpect100ContinueForPuts()}.
32+
* request. This behavior can be disabled via {@link S3Configuration#expectContinueEnabled()}.
3333
*/
3434
@SdkInternalApi
3535
//TODO: This should be generalized for all streaming requests
@@ -68,7 +68,7 @@ private boolean shouldAddExpectContinueHeader(Context.ModifyHttpRequest context,
6868
private boolean isExpect100ContinueDisabled(ExecutionAttributes executionAttributes) {
6969
ServiceConfiguration serviceConfig = executionAttributes.getAttribute(SdkExecutionAttribute.SERVICE_CONFIG);
7070
if (serviceConfig instanceof S3Configuration) {
71-
return ((S3Configuration) serviceConfig).disableExpect100ContinueForPuts();
71+
return !((S3Configuration) serviceConfig).expectContinueEnabled();
7272
}
7373
return false;
7474
}

services/s3/src/test/java/software/amazon/awssdk/services/s3/S3ConfigurationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void createConfiguration_minimal() {
4646
assertThat(config.multiRegionEnabled()).isEqualTo(true);
4747
assertThat(config.pathStyleAccessEnabled()).isEqualTo(false);
4848
assertThat(config.useArnRegionEnabled()).isEqualTo(false);
49-
assertThat(config.disableExpect100ContinueForPuts()).isEqualTo(false);
49+
assertThat(config.expectContinueEnabled()).isEqualTo(true);
5050
}
5151

5252
@Test

services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/Expect100ContinueHeaderTest.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
* These tests verify the header is correctly omitted for zero-length bodies and included for
7272
* non-empty bodies in both sync and async S3 operations.
7373
* <p>
74-
* Also verifies that {@link S3Configuration#disableExpect100ContinueForPuts()} suppresses the header
74+
* Also verifies that {@link S3Configuration#expectContinueEnabled()} suppresses the header
7575
* for all put operations regardless of body content, across all HTTP client types.
7676
*/
7777
@WireMockTest(httpsEnabled = true)
@@ -218,12 +218,12 @@ void asyncOperation_whenPublisherNonEmptyBody_shouldSendExpectHeader(
218218
}
219219

220220
// -----------------------------------------------------------------------
221-
// disableExpect100ContinueForPuts: parameterized across HTTP client types
221+
// expectContinueEnabled: parameterized across HTTP client types
222222
// -----------------------------------------------------------------------
223223

224224
@ParameterizedTest(name = "PutObject: {0}")
225-
@MethodSource("expectContinueDisableConfigProvider")
226-
void putObject_whenDisableExpect100ContinueConfigured_shouldMatchExpectedBehavior(
225+
@MethodSource("expectContinueConfigProvider")
226+
void putObject_whenExpectContinueConfigured_shouldMatchExpectedBehavior(
227227
String testName, String clientType, S3Configuration config,
228228
boolean expectHeaderPresent, WireMockRuntimeInfo wmRuntimeInfo) throws Exception {
229229
stubAnyPutRequest();
@@ -232,8 +232,8 @@ void putObject_whenDisableExpect100ContinueConfigured_shouldMatchExpectedBehavio
232232
}
233233

234234
@ParameterizedTest(name = "UploadPart: {0}")
235-
@MethodSource("expectContinueDisableConfigProvider")
236-
void uploadPart_whenDisableExpect100ContinueConfigured_shouldMatchExpectedBehavior(
235+
@MethodSource("expectContinueConfigProvider")
236+
void uploadPart_whenExpectContinueConfigured_shouldMatchExpectedBehavior(
237237
String testName, String clientType, S3Configuration config,
238238
boolean expectHeaderPresent, WireMockRuntimeInfo wmRuntimeInfo) throws Exception {
239239
stubAnyPutRequest();
@@ -284,41 +284,41 @@ private void executeS3Operation(String clientType, WireMockRuntimeInfo wmInfo,
284284
// Test data providers
285285
// -----------------------------------------------------------------------
286286

287-
private static Stream<Arguments> expectContinueDisableConfigProvider() {
287+
private static Stream<Arguments> expectContinueConfigProvider() {
288288
S3Configuration disabledConfig = S3Configuration.builder()
289-
.disableExpect100ContinueForPuts(true)
289+
.expectContinueEnabled(false)
290290
.build();
291291
S3Configuration enabledConfig = S3Configuration.builder()
292-
.disableExpect100ContinueForPuts(false)
292+
.expectContinueEnabled(true)
293293
.build();
294294

295295
return Stream.of(
296-
// Apache: default expectContinueEnabled=true — both interceptor and Apache add the header
296+
// Apache: default — both interceptor and Apache add the header
297297
Arguments.of("Apache - default config", "APACHE", null, true),
298-
Arguments.of("Apache - S3Config disabled=false", "APACHE", enabledConfig, true),
299-
// Apache: S3Config disabled stops the interceptor, but Apache still adds the header independently
300-
Arguments.of("Apache - S3Config disabled=true (Apache still adds)", "APACHE", disabledConfig, true),
301-
// Apache with expectContinueEnabled=false + S3Config disabled: fully suppressed
302-
Arguments.of("Apache(ec=false) + S3Config disabled=true", "APACHE_EC_DISABLED", disabledConfig, false),
303-
// Apache with expectContinueEnabled=true + S3Config disabled: Apache still adds the header independently
304-
Arguments.of("Apache(ec=true) + S3Config disabled=true", "APACHE_EC_ENABLED", disabledConfig, true),
298+
Arguments.of("Apache - S3Config enabled=true", "APACHE", enabledConfig, true),
299+
// Apache: S3Config enabled=false stops the interceptor, but Apache still adds the header independently
300+
Arguments.of("Apache - S3Config enabled=false (Apache still adds)", "APACHE", disabledConfig, true),
301+
// Apache with ec=false + S3Config enabled=false: fully suppressed
302+
Arguments.of("Apache(ec=false) + S3Config enabled=false", "APACHE_EC_DISABLED", disabledConfig, false),
303+
// Apache with ec=true + S3Config enabled=false: Apache still adds the header independently
304+
Arguments.of("Apache(ec=true) + S3Config enabled=false", "APACHE_EC_ENABLED", disabledConfig, true),
305305

306306
// URL Connection: only the interceptor adds the header
307307
Arguments.of("UrlConnection - default config", "URL_CONNECTION", null, true),
308-
Arguments.of("UrlConnection - S3Config disabled=true", "URL_CONNECTION", disabledConfig, false),
308+
Arguments.of("UrlConnection - S3Config enabled=false", "URL_CONNECTION", disabledConfig, false),
309309

310310
// CRT sync (generic HTTP client): only the interceptor adds the header
311311
Arguments.of("CrtSync - default config", "CRT_SYNC", null, true),
312-
Arguments.of("CrtSync - S3Config disabled=true", "CRT_SYNC", disabledConfig, false),
312+
Arguments.of("CrtSync - S3Config enabled=false", "CRT_SYNC", disabledConfig, false),
313313

314314
// Netty: only the interceptor adds the header
315315
Arguments.of("Netty - default config", "NETTY", null, true),
316-
Arguments.of("Netty - S3Config disabled=false", "NETTY", enabledConfig, true),
317-
Arguments.of("Netty - S3Config disabled=true", "NETTY", disabledConfig, false),
316+
Arguments.of("Netty - S3Config enabled=true", "NETTY", enabledConfig, true),
317+
Arguments.of("Netty - S3Config enabled=false", "NETTY", disabledConfig, false),
318318

319319
// CRT async (generic HTTP client): only the interceptor adds the header
320320
Arguments.of("CrtAsync - default config", "CRT_ASYNC", null, true),
321-
Arguments.of("CrtAsync - S3Config disabled=true", "CRT_ASYNC", disabledConfig, false)
321+
Arguments.of("CrtAsync - S3Config enabled=false", "CRT_ASYNC", disabledConfig, false)
322322
);
323323
}
324324

0 commit comments

Comments
 (0)