Skip to content

Commit

Permalink
npm run lint:fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ifduyue committed Jul 11, 2024
1 parent 2f28ddf commit 5eff8ef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,17 @@ module.exports = {
throw e;
}

const responseReceivedExtraInfo = responseReceivedExtraInfos.find(responseReceivedExtraInfo => responseReceivedExtraInfo.requestId == params.requestId);
if (responseReceivedExtraInfo && responseReceivedExtraInfo.headers) {
entry.response.headers = parseHeaders(responseReceivedExtraInfo.headers);
const responseReceivedExtraInfo = responseReceivedExtraInfos.find(
responseReceivedExtraInfo =>
responseReceivedExtraInfo.requestId == params.requestId
);
if (
responseReceivedExtraInfo &&
responseReceivedExtraInfo.headers
) {
entry.response.headers = parseHeaders(
responseReceivedExtraInfo.headers
);
}
}
break;
Expand Down
23 changes: 13 additions & 10 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,19 @@ test('Includes initial redirect', t => {
});
});

test("Network.responseReceivedExtraInfo may be fired before or after responseReceived", t => {
test('Network.responseReceivedExtraInfo may be fired before or after responseReceived', t => {
const perflogPath = perflog('bing.com.json');
return parsePerflog(perflogPath)
.then(har => har.log)
.then(log => log.entries)
.then(entries => {
const checkingEntries = entries.filter(x => x._requestId == "98243.71");
t.is(checkingEntries.length, 1);
const entry = checkingEntries[0];
// set-cookie header only exists in Network.responseReceivedExtraInfo event
t.is(entry.response.headers.filter(x => x.name == "set-cookie").length, 1);
});
.then(har => har.log)
.then(log => log.entries)
.then(entries => {
const checkingEntries = entries.filter(x => x._requestId == '98243.71');
t.is(checkingEntries.length, 1);
const entry = checkingEntries[0];
// set-cookie header only exists in Network.responseReceivedExtraInfo event
t.is(
entry.response.headers.filter(x => x.name == 'set-cookie').length,
1
);
});
});

0 comments on commit 5eff8ef

Please sign in to comment.