Skip to content

Commit

Permalink
Network.responseReceivedExtraInfo may be fired before or after respon…
Browse files Browse the repository at this point in the history
…seReceived (#120)

* Network.responseReceivedExtraInfo may be fired before or after responseReceived

From https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-responseReceivedExtraInfo

    responseReceivedExtraInfo may be fired before or after responseReceived.
  • Loading branch information
ifduyue authored Jul 12, 2024
1 parent e1b7c6c commit 4f3c43f
Show file tree
Hide file tree
Showing 3 changed files with 77,050 additions and 8 deletions.
25 changes: 17 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module.exports = {
entriesWithoutPage = [],
responsesWithoutPage = [],
paramsWithoutPage = [],
responseReceivedExtraInfos = [],
currentPageId;

for (const message of messages) {
Expand Down Expand Up @@ -336,11 +337,7 @@ module.exports = {
}

if (!entry) {
debug(
`Received response extra info for requestId ${
params.requestId
} with no matching request.`
);
responseReceivedExtraInfos.push(params);
continue;
}

Expand All @@ -350,13 +347,12 @@ module.exports = {
headers: parseHeaders(params.headers),
blockedCookies: params.blockedCookies
};
responseReceivedExtraInfos.push(params);
continue;
}

if (params.headers) {
entry.response.headers = entry.response.headers.concat(
parseHeaders(params.headers)
);
entry.response.headers = parseHeaders(params.headers);
}
}
break;
Expand Down Expand Up @@ -418,6 +414,19 @@ module.exports = {
);
throw e;
}

const responseReceivedExtraInfo = responseReceivedExtraInfos.find(
responseReceivedExtraInfo =>
responseReceivedExtraInfo.requestId == params.requestId
);
if (
responseReceivedExtraInfo &&
responseReceivedExtraInfo.headers
) {
entry.response.headers = parseHeaders(
responseReceivedExtraInfo.headers
);
}
}
break;

Expand Down
Loading

0 comments on commit 4f3c43f

Please sign in to comment.