-
-
Notifications
You must be signed in to change notification settings - Fork 976
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
fix: multipart formdata interpolation #2321
base: main
Are you sure you want to change the base?
Conversation
@@ -186,6 +195,12 @@ const runSingleRequest = async function ( | |||
request.data = qs.stringify(request.data); | |||
} | |||
|
|||
if (request.headers['content-type'] === 'multipart/form-data' && !request.__bruno__bodySetViaMethodCall) { |
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 checking of the Body was set inside a script. Wouldn't it be better to check if the body is already a FormData
object?
What if a user has a script like this:
const originalBody = req.getBody();
const calculated = 'Imagine this is calculated';
req.setBody({
...originalBody,
'script-val': calculated,
})
Now the plain object is sent to the server.
extend(axiosRequest.headers, form.getHeaders()); | ||
axiosRequest.data = form; | ||
each(enabledParams, (p) => (params[p.name] = p.value)); | ||
axiosRequest.data = params; |
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.
This introduces the same breaking change from my PR, where req.body
becomes a plain Key-Value object instead of a FormData
object.
~ multipart formdata interpolation
~ also considers scenarios when the body is set using a pre-request script
multipart-form-data-interpolation.mov
_multipart-form-data-interpolation-cli.mp4