Repository navigation
feat: add opt-in multipart form uploads - #81
Merged
Merged
Conversation
Separate request-body length from replayability so a known-length one-shot stream can use Content-Length without becoming replayable. Encode multipart/form-data above Client::execute behind the multipart feature, and align redirect follow-ups with the selected RFC 9110 method rules.
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
Adds an opt-in
multipartfeature that encodesmultipart/form-dataaboveClient::execute.Form/Partproduce an ordinaryRequestBodyand ownContent-Type; the connector and execution chain stay unchanged.Request-body length is now independent of replayability:
RequestBody::content_length()is the construction-time DATA length. Bridge framing reads it, so a known-length one-shot stream usesContent-Lengthand still cannot be cloned.RequestBody::concatcomposes DATA-only children without buffering payloads.from_stream_with_lengthcounts bytes and rejects length mismatches while the source is polled.from_bodykeeps an unknown framing length even whensize_hint()is exact, so trailers are not suppressed.InvalidRequestbefore I/O. HTTP/2 uploads omitTransfer-Encoding.Redirect follow-ups on the touched coordinator path now match the selected RFC 9110 behavior:
301/302rewrite POST to GET and drop the body. Other methods keep the method and body when the body is replayable.303becomes GET, except HEAD, which stays HEAD.307/308preserve the method. A one-shot body is returned to the caller instead of being replayed.Content-Language,Content-Location,Digest,Last-Modified,Content-Digest, andRepr-Digest.Replayable text/bytes forms can still be retried, redirected, and authenticated. A stream part, including one with a declared length, cannot.
Design notes and the requirement-to-test map are in
docs/multipart-design.md.Verification
cargo fmt --all --checkcargo test -p openwire-core --all-features --lib(56 passed)cargo test -p openwire --all-features --lib --tests(lib 291 passed; integration suites includingmultipart,redirect,auth,pool_http2,events, andcompression_bridgepassed)cargo build -p openwire --all-features --example post_multipartLive-network tests stayed ignored.