mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-26 22:25:40 +00:00
oauth2 fixes, ui validations, timeline updates (wip)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useRef, forwardRef, useState } from 'react';
|
||||
import React, { useRef, forwardRef, useState, useMemo } from 'react';
|
||||
import get from 'lodash/get';
|
||||
import { useTheme } from 'providers/Theme';
|
||||
import { useDispatch } from 'react-redux';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useRef, forwardRef, useState } from 'react';
|
||||
import React, { useRef, forwardRef, useState, useMemo } from 'react';
|
||||
import get from 'lodash/get';
|
||||
import { useTheme } from 'providers/Theme';
|
||||
import { useDispatch } from 'react-redux';
|
||||
|
||||
@@ -13,7 +13,7 @@ import { useTheme } from 'providers/Theme/index';
|
||||
import { getEncoding, prettifyJson, uuid } from 'utils/common/index';
|
||||
|
||||
const formatResponse = (data, dataBuffer, encoding, mode, filter) => {
|
||||
if (data === undefined || !dataBuffer) {
|
||||
if (data === undefined || !dataBuffer || !mode) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ const QueryResult = ({ item, collection, data, dataBuffer, width, disableRunEven
|
||||
// Always show raw
|
||||
const allowedPreviewModes = [{ mode: 'raw', name: 'Raw', uid: uuid() }];
|
||||
|
||||
if (!mode) return;
|
||||
if (!mode || !contentType) return;
|
||||
|
||||
if (mode?.includes('html') && typeof data === 'string') {
|
||||
allowedPreviewModes.unshift({ mode: 'preview-web', name: 'Web', uid: uuid() });
|
||||
|
||||
@@ -238,28 +238,26 @@ function makeAxiosInstance({
|
||||
const duration = end - metadata.startTime;
|
||||
|
||||
if (error.response && redirectResponseCodes.includes(error.response.status)) {
|
||||
metadata.timeline.push({
|
||||
timestamp: new Date(),
|
||||
type: 'response',
|
||||
message: `HTTP/${error.response.httpVersion || '1.1'} ${error.response.status} ${error.response.statusText}`,
|
||||
});
|
||||
Object.entries(error.response.headers).forEach(([key, value]) => {
|
||||
metadata.timeline.push({
|
||||
timestamp: new Date(),
|
||||
type: 'responseHeader',
|
||||
message: `${key}: ${value}`,
|
||||
});
|
||||
});
|
||||
metadata.timeline.push({
|
||||
timestamp: new Date(),
|
||||
type: 'info',
|
||||
message: `Request completed in ${duration} ms`,
|
||||
});
|
||||
|
||||
|
||||
metadata.timeline.push({
|
||||
timestamp: new Date(),
|
||||
type: 'response',
|
||||
message: `HTTP/${error.response.httpVersion || '1.1'} ${error.response.status} ${error.response.statusText}`,
|
||||
});
|
||||
Object.entries(error.response.headers).forEach(([key, value]) => {
|
||||
metadata.timeline.push({
|
||||
timestamp: new Date(),
|
||||
type: 'responseHeader',
|
||||
message: `${key}: ${value}`,
|
||||
});
|
||||
});
|
||||
metadata.timeline.push({
|
||||
timestamp: new Date(),
|
||||
type: 'info',
|
||||
message: `Request completed in ${duration} ms`,
|
||||
});
|
||||
|
||||
// Attach the timeline to the response
|
||||
error.response.timeline = metadata.timeline;
|
||||
// Attach the timeline to the response
|
||||
error.response.timeline = metadata.timeline;
|
||||
|
||||
if (redirectCount >= requestMaxRedirects) {
|
||||
const dataBuffer = Buffer.from(error.response.data);
|
||||
@@ -271,7 +269,8 @@ function makeAxiosInstance({
|
||||
data: error.response.data,
|
||||
dataBuffer: dataBuffer.toString('base64'),
|
||||
size: Buffer.byteLength(dataBuffer),
|
||||
duration: error.response.headers.get('request-duration') ?? 0
|
||||
duration: error.response.headers.get('request-duration') ?? 0,
|
||||
timeline: error.response.timeline
|
||||
};
|
||||
}
|
||||
|
||||
@@ -313,7 +312,6 @@ function makeAxiosInstance({
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setupProxyAgents({
|
||||
requestConfig,
|
||||
proxyMode,
|
||||
@@ -329,10 +327,10 @@ function makeAxiosInstance({
|
||||
}
|
||||
else if (error?.code) {
|
||||
let metadata = error?.config?.metadata;
|
||||
metadata.timeline.push({
|
||||
metadata?.timeline?.push({
|
||||
timestamp: new Date(),
|
||||
type: 'error',
|
||||
message: safeStringifyJSON(error?.errors)
|
||||
message: `${safeStringifyJSON(error?.cause) || ''}\n${safeStringifyJSON(error?.errors) || ''}`
|
||||
});
|
||||
return {
|
||||
status: '-',
|
||||
|
||||
Reference in New Issue
Block a user