mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 23:43:15 +01:00
feat: Store cookies received in Runner execution (#2951)
This commit is contained in:
parent
2a93a6fa65
commit
5931f0bb4e
@ -88,6 +88,22 @@ const getJsSandboxRuntime = (collection) => {
|
||||
|
||||
const protocolRegex = /^([-+\w]{1,25})(:?\/\/|:)/;
|
||||
|
||||
const saveCookies = (url, headers) => {
|
||||
if (preferencesUtil.shouldStoreCookies()) {
|
||||
let setCookieHeaders = [];
|
||||
if (headers['set-cookie']) {
|
||||
setCookieHeaders = Array.isArray(headers['set-cookie'])
|
||||
? headers['set-cookie']
|
||||
: [headers['set-cookie']];
|
||||
for (let setCookieHeader of setCookieHeaders) {
|
||||
if (typeof setCookieHeader === 'string' && setCookieHeader.length) {
|
||||
addCookieToJar(setCookieHeader, url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const configureRequest = async (
|
||||
collectionUid,
|
||||
request,
|
||||
@ -590,17 +606,7 @@ const registerNetworkIpc = (mainWindow) => {
|
||||
|
||||
// save cookies
|
||||
if (preferencesUtil.shouldStoreCookies()) {
|
||||
let setCookieHeaders = [];
|
||||
if (response.headers['set-cookie']) {
|
||||
setCookieHeaders = Array.isArray(response.headers['set-cookie'])
|
||||
? response.headers['set-cookie']
|
||||
: [response.headers['set-cookie']];
|
||||
for (let setCookieHeader of setCookieHeaders) {
|
||||
if (typeof setCookieHeader === 'string' && setCookieHeader.length) {
|
||||
addCookieToJar(setCookieHeader, request.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
saveCookies(request.url, response.headers);
|
||||
}
|
||||
|
||||
// send domain cookies to renderer
|
||||
@ -1016,6 +1022,16 @@ const registerNetworkIpc = (mainWindow) => {
|
||||
response.data = data;
|
||||
response.responseTime = response.headers.get('request-duration');
|
||||
|
||||
// save cookies
|
||||
if (preferencesUtil.shouldStoreCookies()) {
|
||||
saveCookies(request.url, response.headers);
|
||||
}
|
||||
|
||||
// send domain cookies to renderer
|
||||
const domainsWithCookies = await getDomainsWithCookies();
|
||||
|
||||
mainWindow.webContents.send('main:cookies-update', safeParseJSON(safeStringifyJSON(domainsWithCookies)));
|
||||
|
||||
mainWindow.webContents.send('main:run-folder-event', {
|
||||
type: 'response-received',
|
||||
responseReceived: {
|
||||
|
Loading…
Reference in New Issue
Block a user