mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-07 14:08:38 +00:00
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:
committed by
GitHub
parent
53b75d083f
commit
bbf3cb8dd3
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user