Skip to content

Commit

Permalink
Fixing batch request/response headers in inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
ehamai committed Dec 21, 2023
1 parent 5506a08 commit 5e66b77
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
17 changes: 14 additions & 3 deletions src/common/batchConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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: {
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/components/NameValueList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/components/TraceInspector/HeadersTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down

0 comments on commit 5e66b77

Please sign in to comment.