-
Notifications
You must be signed in to change notification settings - Fork 186
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
support nested multipart, strict no-content parts CRLF and better part metadata resolution #380
Open
fmigneault
wants to merge
12
commits into
requests:master
Choose a base branch
from
crim-ca:patch-multipart
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
…ng from no contents
…n if provided by headers
fmigneault
changed the title
support nested multipart and no-conent parts
support nested multipart, strict no-content parts CRLF and better part metadata resolution
Sep 25, 2024
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)
Hi. |
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),MultipartEncoder
will not incorrectly insert a second\r\n
anymore. A parser that strictly interprets the amount of\r\n
can distinguish a "no content" part from an "empty string" part, which can have different meanings depending on the embeddedContent-Type
(e.g.: anull
vs""
for JSON).Fixes requests_toolbelt.multipart.decoder.ImproperBodyPartContentException: content does not contain CR-LF-CR-LF #352.
Multipart decoder correctly understands a single
\r\n
used to separate the headers from the "no content" body. The resulting part returnsNone
rather than""
. A part still using CR-LF-CR-LF explicitly will enclose an empty string.Add a
content_type
parameter to__init__
allowing to override the defaultmultipart/form-data
that was hard-coded.Support nested multipart.
Using the
MultipartEncoder
asfile_pointer
in the inputfields
of anotherMultipartEncoder
will correctly nest the contents, with their respective boundaries. This can be used to form complex structures ofmultipart/mixed
,multipart/alternate
,multipart/related
commonly used when combining various attachment representations.When
headers
are provided for one of the parts, ensure that anyContent-Type
,Content-Location
orContent-Disposition
explicitly provided in them are not overridden by theurllib3.fields.make_multipart
step. This allows using other dispositions thanform-data
, such asattachment
orinline
as needed.