Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lohxt1
Copy link
Collaborator

@lohxt1 lohxt1 commented May 16, 2024

~ 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

@lohxt1 lohxt1 changed the title Fix/multipart interpolation fix: multipart formdata interpolation May 16, 2024
@@ -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) {
Copy link
Member

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;
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants