fix: preserve user-defined boundary in multipart/mixed Content-Type header (#7531)

* fix: preserve user-defined boundary in multipart/mixed Content-Type header

When users specify a boundary parameter in their Content-Type header for
multipart/mixed requests with TEXT body mode, Bruno now preserves the
user-defined boundary instead of generating a new one.

Fixes: https://github.com/usebruno/bruno/issues/7523

* updated the test to use local server and changed the request method to GET

* fix: handle quoted boundary values in Content-Type header extraction

---------

Co-authored-by: Chirag Chandrashekhar <cchirag85@gmail.com>
This commit is contained in:
Chirag Chandrashekhar
2026-03-27 16:49:50 +05:30
committed by GitHub
parent 53b75d083f
commit bbf3cb8dd3
7 changed files with 264 additions and 6 deletions

View File

@@ -26,7 +26,7 @@ const { addDigestInterceptor, getHttpHttpsAgents, makeAxiosInstance: makeAxiosIn
const { getCACertificates, transformProxyConfig, getOrCreateHttpsAgent, getOrCreateHttpAgent } = require('@usebruno/requests');
const { getOAuth2Token, getFormattedOauth2Credentials } = require('../utils/oauth2');
const tokenStore = require('../store/tokenStore');
const { encodeUrl, buildFormUrlEncodedPayload, extractPromptVariables, isFormData } = require('@usebruno/common').utils;
const { encodeUrl, buildFormUrlEncodedPayload, extractPromptVariables, isFormData, extractBoundaryFromContentType } = require('@usebruno/common').utils;
const onConsoleLog = (type, args) => {
console[type](...args);
@@ -570,7 +570,12 @@ const runSingleRequest = async function (
if (contentType !== 'multipart/form-data') {
// Patch: Axios leverages getHeaders method to get the headers so FormData should be monkey patched
const formHeaders = form.getHeaders();
formHeaders['content-type'] = `${contentType}; boundary=${form.getBoundary()}`;
const existingBoundary = extractBoundaryFromContentType(contentType);
if (existingBoundary) {
formHeaders['content-type'] = contentType;
} else {
formHeaders['content-type'] = `${contentType}; boundary=${form.getBoundary()}`;
}
form.getHeaders = function () {
return formHeaders;
};