feat(#1050): Response time in res

This commit is contained in:
Shourav Nath 2023-11-25 12:44:39 +06:00
parent f0d5cdecb7
commit fa7afd4237
5 changed files with 12 additions and 0 deletions

View File

@ -27,10 +27,12 @@ if (!SERVER_RENDERED) {
'res.statusText', 'res.statusText',
'res.headers', 'res.headers',
'res.body', 'res.body',
'res.responseTime',
'res.getStatus()', 'res.getStatus()',
'res.getHeader(name)', 'res.getHeader(name)',
'res.getHeaders()', 'res.getHeaders()',
'res.getBody()', 'res.getBody()',
'res.getResponseTime()',
'req', 'req',
'req.url', 'req.url',
'req.method', 'req.method',

View File

@ -210,6 +210,8 @@ const runSingleRequest = async function (
} }
} }
response.responseTime = responseTime;
console.log( console.log(
chalk.green(stripExtension(filename)) + chalk.green(stripExtension(filename)) +
chalk.dim(` (${response.status} ${response.statusText}) - ${responseTime} ms`) chalk.dim(` (${response.status} ${response.statusText}) - ${responseTime} ms`)

View File

@ -446,6 +446,8 @@ const registerNetworkIpc = (mainWindow) => {
const { data, dataBuffer } = parseDataFromResponse(response); const { data, dataBuffer } = parseDataFromResponse(response);
response.data = data; response.data = data;
response.responseTime = responseTime;
// save cookies // save cookies
let setCookieHeaders = []; let setCookieHeaders = [];
if (response.headers['set-cookie']) { if (response.headers['set-cookie']) {

View File

@ -5,6 +5,7 @@ class BrunoResponse {
this.statusText = res ? res.statusText : null; this.statusText = res ? res.statusText : null;
this.headers = res ? res.headers : null; this.headers = res ? res.headers : null;
this.body = res ? res.data : null; this.body = res ? res.data : null;
this.responseTime = res ? res.responseTime : null;
} }
getStatus() { getStatus() {
@ -22,6 +23,10 @@ class BrunoResponse {
getBody() { getBody() {
return this.res ? this.res.data : null; return this.res ? this.res.data : null;
} }
getResponseTime() {
return this.res ? this.res.responseTime : null;
}
} }
module.exports = BrunoResponse; module.exports = BrunoResponse;

View File

@ -109,6 +109,7 @@ const createResponseParser = (response = {}) => {
res.statusText = response.statusText; res.statusText = response.statusText;
res.headers = response.headers; res.headers = response.headers;
res.body = response.data; res.body = response.data;
res.responseTime = response.responseTime;
res.jq = (expr) => { res.jq = (expr) => {
const output = jsonQuery(expr, { data: response.data }); const output = jsonQuery(expr, { data: response.data });