Closed zacard-orc closed 4 years ago
I was receiving a similar error and was stumped. It was because I was sending params in the wrong format to Fetch.enable
which ends up defaulting to intercepting everything but at the Request
stage. An error message on invalid or unrecognized parameters would be helpful.
Here's code that shows a working implementation.
const puppeteer = require("puppeteer");
test();
async function test() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const client = await page.target().createCDPSession();
await client.send("Fetch.enable", {
patterns: [{ requestStage: "Response" }]
});
client.on("Fetch.requestPaused", async event => {
const { requestId } = event;
console.log(`Request "${requestId}" paused.`);
const responseCdp = await client.send("Fetch.getResponseBody", { requestId });
console.log(`Response body for ${requestId} is ${responseCdp.body.length} bytes`);
await client.send("Fetch.continueRequest", { requestId });
});
await page.goto("http://example.com");
return browser.close();
}
This repository is related to Chrome DevTools Protocol, but does not track issues regarding its definition or implementation. If you want to file an issue for the Chrome DevTools Protocol, please open an issue on https://crbug.com under component: Platform>DevTools>Platform
. Thanks in advance!
i want tirgger the fetch.authrequired method but for fetch.enable method it will trigger the fetch.requestPaused event .evevn though i set handleAuthRequests true.
Hello , when I use Fetch.getResponseBody after Fetch.requestPaused & Fetch.continueRequest by FinishLoading event trigger , the devtool console always tell me " Can only get response body on HeadersReceived pattern matched requests "
eg. here is my request websocket body let cdata2={ id:customId, method:'Fetch.getResponseBody', params:{ requestId:hookRequestIdList.shift() } }; customeId ++;
Dose anybody help me~,pls ~