diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js index 5bef312e8..79cc0b714 100644 --- a/packages/bruno-electron/src/ipc/network/index.js +++ b/packages/bruno-electron/src/ipc/network/index.js @@ -37,6 +37,7 @@ const { cookiesStore } = require('../../store/cookies'); const registerGrpcEventHandlers = require('./grpc-event-handlers'); const { registerWsEventHandlers } = require('./ws-event-handlers'); const { getCertsAndProxyConfig, buildCertsAndProxyConfig } = require('./cert-utils'); +const { easterEggResponse } = require('../../utils/woof'); const { buildFormUrlEncodedPayload, isFormData, extractBoundaryFromContentType } = require('@usebruno/common').utils; const ERROR_OCCURRED_WHILE_EXECUTING_REQUEST = 'Error occurred while executing the request!'; @@ -873,6 +874,12 @@ const registerNetworkIpc = (mainWindow) => { const abortController = new AbortController(); const request = await prepareRequest(item, collection, abortController); + + // Every good boy deserves a response. + if (request.method && request.method.toUpperCase() === 'WOOF') { + return easterEggResponse(request); + } + request.__bruno__executionMode = 'standalone'; request.responseType = 'stream'; // flag to see if the stream needs to be handled as an actual stream or diff --git a/packages/bruno-electron/src/utils/woof.js b/packages/bruno-electron/src/utils/woof.js new file mode 100644 index 000000000..3e3bb3e46 --- /dev/null +++ b/packages/bruno-electron/src/utils/woof.js @@ -0,0 +1,38 @@ +const easterEggResponse = (request) => { + const woofStart = Date.now(); + const body = [ + 'Woof! Woof!', + '', + ' __', + ' (___()\'`;', + ' /, /`', + ' \\\\"--\\\\', + '', + 'Bruno fetched your request. Good human.' + ].join('\n'); + const buffer = Buffer.from(body, 'utf-8'); + return { + status: 200, + statusText: 'Woof!', + headers: { + 'content-type': 'text/plain; charset=utf-8', + 'x-good-boy': 'true', + 'x-fetched-by': 'bruno' + }, + data: body, + dataBuffer: buffer.toString('base64'), + size: buffer.byteLength, + duration: Date.now() - woofStart, + url: request.url, + timeline: [], + requestSent: { + url: request.url, + method: 'WOOF', + headers: request.headers, + data: null, + timestamp: woofStart + } + }; +}; + +module.exports = { easterEggResponse };