-
Notifications
You must be signed in to change notification settings - Fork 942
Skip 'Expect: 100-continue' header for zero-length S3 streaming requests #6465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
bad553d
to
32853df
Compare
return context.requestBody() | ||
.flatMap(RequestBody::optionalContentLength) | ||
.map(length -> length != 0L) | ||
.orElse(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about async request body? The length could also be sourced from the request itself, i.e, putObjectRequest.contentLength()
. Should we check header instead? It could be content-length
or x-amz-decoded-content-length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, we should probably give priority to x-amz-decoded-content-length
and just fall back to content-length
. If the decoded length is present and 0, then it's just the trailer and I don't think we need to use expect: 100-continue
for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...n/java/software/amazon/awssdk/services/s3/internal/handlers/StreamingRequestInterceptor.java
Outdated
Show resolved
Hide resolved
75beb91
to
04e9ec5
Compare
|
Motivation and Context
Fix for #6459
Per RFC 9110 Section 10.1.1, clients MUST NOT generate a 100-continue expectation in requests that do not include content. Currently, the SDK adds the
Expect: 100-continue
header to all S3 PutObject and UploadPart requests, including those with zero-length content.This causes issues with sync HTTP clients (e.g., Apache HttpClient) that reuse connections. When a zero-length request is sent with the Expect header, the server may close the connection after receiving the empty content, but the client attempts to reuse it, leading to connection errors.
RFC 9110 Reference:
Modifications
Updated
StreamingRequestInterceptor
to skip adding theExpect: 100-continue
header when:Key Changes:
shouldAddExpectContinueHeader()
method to check for zero-length contentBehavior:
Optional.empty()
0L
> 0L
Testing
Added test coverage in
StreamingRequestInterceptorTest
:Screenshots (if appropriate)
N/A - Code-only change
Types of changes
License
Notes
Apache 5.x
https://github.com/arturobernalg/httpcomponents-client/blob/237b5f85f743c94d9be2d26d396130bc2053f2ef/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestExpectContinue.java#L85-L88
Apache 4.5.x
https://github.com/apache/httpcomponents-client/blob/54900db4653d7f207477e6ee40135b88e9bcf832/httpclient/src/main/java/org/apache/http/client/protocol/RequestExpectContinue.java#L73-L75