mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-25 05:35:41 +00:00
feat(woof): add WOOF easter egg (#8301)
* feat(woof): add WOOF easter egg * refactor(woof): extract WOOF response logic into a separate utility function * refactor: rename the response function
This commit is contained in:
@@ -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
|
||||
|
||||
38
packages/bruno-electron/src/utils/woof.js
Normal file
38
packages/bruno-electron/src/utils/woof.js
Normal file
@@ -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 };
|
||||
Reference in New Issue
Block a user