support nested multipart, strict no-content parts CRLF and better part metadata resolution#380
Open
fmigneault wants to merge 12 commits intorequests:masterfrom
Open
support nested multipart, strict no-content parts CRLF and better part metadata resolution#380fmigneault wants to merge 12 commits intorequests:masterfrom
fmigneault wants to merge 12 commits intorequests:masterfrom
Conversation
…ng from no contents
…n if provided by headers
fmigneault
added a commit
to crim-ca/weaver
that referenced
this pull request
Sep 25, 2024
…x no-content and nested multipart (relates to requests/toolbelt#380)
Author
|
Hi. |
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.
Features and Fixes
Given a part that has "no content" (
None) (as if it was returned on its own by an HTTP 204 No Content response),MultipartEncoderwill not incorrectly insert a second\r\nanymore. A parser that strictly interprets the amount of\r\ncan distinguish a "no content" part from an "empty string" part, which can have different meanings depending on the embeddedContent-Type(e.g.: anullvs""for JSON).Fixes requests_toolbelt.multipart.decoder.ImproperBodyPartContentException: content does not contain CR-LF-CR-LF #352.
Multipart decoder correctly understands a single
\r\nused to separate the headers from the "no content" body. The resulting part returnsNonerather than"". A part still using CR-LF-CR-LF explicitly will enclose an empty string.Add a
content_typeparameter to__init__allowing to override the defaultmultipart/form-datathat was hard-coded.Support nested multipart.
Using the
MultipartEncoderasfile_pointerin the inputfieldsof anotherMultipartEncoderwill correctly nest the contents, with their respective boundaries. This can be used to form complex structures ofmultipart/mixed,multipart/alternate,multipart/relatedcommonly used when combining various attachment representations.When
headersare provided for one of the parts, ensure that anyContent-Type,Content-LocationorContent-Dispositionexplicitly provided in them are not overridden by theurllib3.fields.make_multipartstep. This allows using other dispositions thanform-data, such asattachmentorinlineas needed.