fix(#1436): fixed inconsistent beheviour of res.getHeaders() api

This commit is contained in:
Anoop M D 2024-01-29 19:46:41 +05:30
parent 00e11e3177
commit 4917f24b7c
4 changed files with 8 additions and 6 deletions

View File

@ -2,6 +2,8 @@ import React from 'react';
import StyledWrapper from './StyledWrapper'; import StyledWrapper from './StyledWrapper';
const ResponseHeaders = ({ headers }) => { const ResponseHeaders = ({ headers }) => {
const headersArray = typeof headers === 'object' ? Object.entries(headers) : [];
return ( return (
<StyledWrapper className="pb-4 w-full"> <StyledWrapper className="pb-4 w-full">
<table> <table>
@ -12,8 +14,8 @@ const ResponseHeaders = ({ headers }) => {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{headers && headers.length {headersArray && headersArray.length
? headers.map((header, index) => { ? headersArray.map((header, index) => {
return ( return (
<tr key={index}> <tr key={index}>
<td className="key">{header[0]}</td> <td className="key">{header[0]}</td>

View File

@ -5,7 +5,7 @@ import StyledWrapper from './StyledWrapper';
const Timeline = ({ request, response }) => { const Timeline = ({ request, response }) => {
const requestHeaders = []; const requestHeaders = [];
const responseHeaders = response.headers || []; const responseHeaders = typeof response.headers === 'object' ? Object.entries(response.headers) : [];
request = request || {}; request = request || {};
response = response || {}; response = response || {};

View File

@ -10,7 +10,7 @@ export const sendNetworkRequest = async (item, collection, environment, collecti
data: response.data, data: response.data,
// Note that the Buffer is encoded as a base64 string, because Buffers / TypedArrays are not allowed in the redux store // Note that the Buffer is encoded as a base64 string, because Buffers / TypedArrays are not allowed in the redux store
dataBuffer: response.dataBuffer, dataBuffer: response.dataBuffer,
headers: Object.entries(response.headers), headers: response.headers,
size: response.size, size: response.size,
status: response.status, status: response.status,
statusText: response.statusText, statusText: response.statusText,

View File

@ -792,7 +792,7 @@ const registerNetworkIpc = (mainWindow) => {
responseReceived: { responseReceived: {
status: response.status, status: response.status,
statusText: response.statusText, statusText: response.statusText,
headers: Object.entries(response.headers), headers: response.headers,
duration: timeEnd - timeStart, duration: timeEnd - timeStart,
dataBuffer: dataBuffer.toString('base64'), dataBuffer: dataBuffer.toString('base64'),
size: Buffer.byteLength(dataBuffer), size: Buffer.byteLength(dataBuffer),
@ -809,7 +809,7 @@ const registerNetworkIpc = (mainWindow) => {
response = { response = {
status: error.response.status, status: error.response.status,
statusText: error.response.statusText, statusText: error.response.statusText,
headers: Object.entries(error.response.headers), headers: error.response.headers,
duration: timeEnd - timeStart, duration: timeEnd - timeStart,
dataBuffer: dataBuffer.toString('base64'), dataBuffer: dataBuffer.toString('base64'),
size: Buffer.byteLength(dataBuffer), size: Buffer.byteLength(dataBuffer),