Repository navigation
fix(s3): send 100 Continue for empty-body Expect requests - #70
Open
kylecannon wants to merge 1 commit into
Open
kylecannon wants to merge 1 commit into
kylecannon wants to merge 1 commit into
Conversation
The Node AWS SDK v3 (@smithy/node-http-handler 2.x) sends `Expect: 100-continue` even on an empty PutObject, then waits for the 100 before finishing the request. Real S3 sends it, so you never see this in production, but against rustack the upload just sits there until the request timeout (5 minutes in our case). hyper skips the 100 when the body is empty, and there's no way to send a 1xx from a service, so this adds a small IO wrapper around each accepted connection. It follows HTTP/1 request and response framing and, when an empty-body request asks for a 100, writes one right before hyper's response. It handles one request at a time per connection. If a client pipelines, or anything looks unusual (HTTP/2, upgrades, close-delimited responses, heads it can't parse), the connection is left alone and behaves exactly as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Node AWS SDK v3 (
@smithy/node-http-handler2.x) sendsExpect: 100-continueeven on an empty PutObject, then waits for the 100 before finishing the request. Real S3 sends the 100 (checked against a us-west-2 bucket), and so does LocalStack, so against rustack the upload just sits there until the client's request timeout.hyper skips the 100 when the body is empty, and a service can't send a 1xx itself, so this adds a small IO wrapper around each accepted connection. It follows HTTP/1 request and response framing, and when an empty-body request asked for a 100 it writes
HTTP/1.1 100 Continueright before hyper's response.It handles one request at a time per connection. If a client pipelines, or anything looks unusual (HTTP/2, upgrades, close-delimited responses, heads it can't parse), the wrapper steps aside for the rest of the connection and it behaves exactly as before.
What
apps/rustack/src/expect_continue.rs(new): theExpectContinueIowrapper and its tests.apps/rustack/src/main.rs: wraps each accepted stream inExpectContinueIobefore handing it to hyper.Cargo.toml,apps/rustack/Cargo.toml,Cargo.lock: addshttparsefor head parsing.Testing
apps/rustack/src/expect_continue.rscover keep-alive, chunked bodies, split heads, pipelining, backpressure and HTTP/2 pass-through;cargo test -p rustack-clipasses.@aws-sdk/client-s3with the 2.x handler: hung until the 15 s request timeout before, 3 ms after.