Honor multipart boundary from an explicit Content-Type header#1896
Open
Synvoya wants to merge 1 commit into
Open
Honor multipart boundary from an explicit Content-Type header#1896Synvoya wants to merge 1 commit into
Content-Type header#1896Synvoya wants to merge 1 commit into
Conversation
When a multipart boundary was supplied only via a Content-Type header (no --boundary flag), HTTPie declared that boundary in the header but wrote the body with a different random boundary, producing an unparseable request. Reconcile the encoder's boundary with the one declared in the header; --boundary still takes precedence.
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.
Description
When a multipart boundary is supplied only via an explicit
Content-Typeheader (without the--boundaryflag), HTTPie declares that boundary in the header but writes the body with a different, random boundary — so the declared boundary never appears in the body and the request is unparseable.This is the workflow requested in #199 (setting the boundary the way
curldoes).Fix
If no
--boundarywas given, read the boundary from theContent-Typeheader (via the existingparse_content_type_header, which is case-insensitive and quote-stripping, soBoundary="..."works too) and use it for the encoder.--boundarystill takes precedence, so the explicit-override behavior is unchanged.Test
Added
test_multipart_boundary_from_content_type_without_flag. Fulltests/test_uploads.pypasses (28); reverting only the fix fails the new test.