From 5e66b7788c05ded5892ea58227a3e8917da382d5 Mon Sep 17 00:00:00 2001 From: Elliott Hamai Date: Thu, 21 Dec 2023 11:33:22 -0800 Subject: [PATCH] Fixing batch request/response headers in inspector --- src/common/batchConverter.ts | 17 ++++++++++++++--- src/components/NameValueList.tsx | 2 +- src/components/TraceInspector/HeadersTab.tsx | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/common/batchConverter.ts b/src/common/batchConverter.ts index b9c821c..5141df2 100644 --- a/src/common/batchConverter.ts +++ b/src/common/batchConverter.ts @@ -3,8 +3,17 @@ import { UberBatchRequest, UberBatchResponse } from "../sanitizer/models/batchRe import { Entry, NameValueKeyPair } from "../sanitizer/models/harFile"; import { isBatchRequest } from "../sanitizer/requestRules/armBatchResponseRule"; -const convertBatchHeadersToHeaders = (batchHeaders: { [id: string]: string }) => { +const convertBatchHeadersToHeaders = (uberBatchHeaders: {[id: string]: string}, batchHeaders: { [id: string]: string }) => { const headers: NameValueKeyPair[] = []; + if(uberBatchHeaders){ + for(const key of Object.keys(uberBatchHeaders)){ + headers.push({ + name: key, + value: uberBatchHeaders[key] + }); + } + } + for (const key of Object.keys(batchHeaders)) { headers.push({ name: key, @@ -36,7 +45,9 @@ export const convertBatchEntryToEntries = (entry: Entry, entries: InspectorEntry request: { method: batchRequest.httpMethod, url: url, - headers: convertBatchHeadersToHeaders(batchRequest.requestHeaderDetails), + + // Headers for individual requests are sent within the uber batch request payload + headers: convertBatchHeadersToHeaders(uberBatchRequest.headers as any, batchRequest.requestHeaderDetails), queryString: [], cookies: [], postData: { @@ -47,7 +58,7 @@ export const convertBatchEntryToEntries = (entry: Entry, entries: InspectorEntry response: { status: batchResponse.httpStatusCode, statusText: '', - headers: convertBatchHeadersToHeaders(batchResponse.headers), + headers: convertBatchHeadersToHeaders({}, batchResponse.headers), cookies: [], content: { mimeType: 'application/json', diff --git a/src/components/NameValueList.tsx b/src/components/NameValueList.tsx index 962b5d4..8067584 100644 --- a/src/components/NameValueList.tsx +++ b/src/components/NameValueList.tsx @@ -16,7 +16,7 @@ const getNameValueContainerStyle = (): React.CSSProperties =>{ const lineHeight = '25px' const getNameStyle =(): React.CSSProperties =>{ return { - minWidth: '150px', + minWidth: '300px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', diff --git a/src/components/TraceInspector/HeadersTab.tsx b/src/components/TraceInspector/HeadersTab.tsx index d497ebe..07cd770 100644 --- a/src/components/TraceInspector/HeadersTab.tsx +++ b/src/components/TraceInspector/HeadersTab.tsx @@ -46,7 +46,7 @@ export const HeadersTab = (props: HeadersTabProps) => { const { isResponseHeaders, entry } = props; const { request, response } = entry; - const headers = request.headers; + const headers = isResponseHeaders ? response.headers : request.headers; // Test parameters // const headers = [];