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.
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
allow setting an explicit multipart boundary via headers #2278
allow setting an explicit multipart boundary via headers #2278
Changes from 7 commits
2688326
b80b96d
5dd17fa
68ffbba
c6e4cdf
20050f0
e4275c1
aa48d29
fabb049
c6a97f2
280c42d
43c2c7a
c845de0
004a81d
2a1e043
5c301cc
38d5357
424beb3
c78fa10
899c820
74de494
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we keep things a little tighter here by passing
content_type: str = None
instead? That restricts the information we're passing around to the one thing we're actually interested in.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup good call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of raising
ValueError
we could just returnNone
if the content type doesn't start with "multipart/form-data", or doesn't include a valid boundary.(Users can currently submit requests with
Content-Type
headers that don't properly match up to the data they include, so just being lax here seems okay to me.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that since
content-type
gets set viasetdefault
. If it already exists, it won't be overwritten. So in the case where the user provided thecontent-type
header but did not provide the multipart boundary we'd be sending out a request with no multipart boundary, which completely violates the spec and no server will be able to parse.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. We could either hard-error in that case, or just ignore it and allow users to do that.
There is also a whole class of cases here where a user can set a
Content-Type
that doesn't match the encoding type they're using withdata=
/files=
/json=
. (Eg. they can setContent-Type: application/json
on either form or multipart requests.) But that's probably okay.