Skip to content

Commit

Permalink
fix(#1436): fixed inconsistent beheviour of res.getHeaders() api
Browse files Browse the repository at this point in the history
  • Loading branch information
helloanoop committed Jan 29, 2024
1 parent 00e11e3 commit 4917f24
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import StyledWrapper from './StyledWrapper';

const ResponseHeaders = ({ headers }) => {
const headersArray = typeof headers === 'object' ? Object.entries(headers) : [];

return (
<StyledWrapper className="pb-4 w-full">
<table>
Expand All @@ -12,8 +14,8 @@ const ResponseHeaders = ({ headers }) => {
</tr>
</thead>
<tbody>
{headers && headers.length
? headers.map((header, index) => {
{headersArray && headersArray.length
? headersArray.map((header, index) => {
return (
<tr key={index}>
<td className="key">{header[0]}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import StyledWrapper from './StyledWrapper';

const Timeline = ({ request, response }) => {
const requestHeaders = [];
const responseHeaders = response.headers || [];
const responseHeaders = typeof response.headers === 'object' ? Object.entries(response.headers) : [];

request = request || {};
response = response || {};
Expand Down
2 changes: 1 addition & 1 deletion packages/bruno-app/src/utils/network/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const sendNetworkRequest = async (item, collection, environment, collecti
data: response.data,
// Note that the Buffer is encoded as a base64 string, because Buffers / TypedArrays are not allowed in the redux store
dataBuffer: response.dataBuffer,
headers: Object.entries(response.headers),
headers: response.headers,
size: response.size,
status: response.status,
statusText: response.statusText,
Expand Down
4 changes: 2 additions & 2 deletions packages/bruno-electron/src/ipc/network/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ const registerNetworkIpc = (mainWindow) => {
responseReceived: {
status: response.status,
statusText: response.statusText,
headers: Object.entries(response.headers),
headers: response.headers,
duration: timeEnd - timeStart,
dataBuffer: dataBuffer.toString('base64'),
size: Buffer.byteLength(dataBuffer),
Expand All @@ -809,7 +809,7 @@ const registerNetworkIpc = (mainWindow) => {
response = {
status: error.response.status,
statusText: error.response.statusText,
headers: Object.entries(error.response.headers),
headers: error.response.headers,
duration: timeEnd - timeStart,
dataBuffer: dataBuffer.toString('base64'),
size: Buffer.byteLength(dataBuffer),
Expand Down

0 comments on commit 4917f24

Please sign in to comment.