await Network.Enable();
await Network.enableRequestInterception({enabled: true});
Network.requestIntercepted((params) => {
let continueParams = {interceptionId: params.InterceptionId};
if (params.request.url.endsWith('.jpg')) {
// Pretend the .jpg IP address was unreachable.
continueParams.errorReason = 'AddressUnreachable';
} else if (params.hasOwnProperty('redirectStatusCode') &&
params.redirectStatusCode == 302) {
// Pretend the server sent a 404 instead of a 302.
continueParams.rawResponse =
btoa("HTTP/1.1 404 Not Found\r\n\r\n");
} else {
// Allow the request to continue as normal.
}
Network.continueInterceptedRequest(continueParams);
});
Page.navigate({url: 'http://some-website.tld/'})
Hi Alex,
That's amazing news! Do you think it would be possible to handle proxy authentication this way? Perhaps the second "most wanted" feature from my list is to be able to manage proxies via CDP in a same way it is already possible via Chrome Extensions.
--
You received this message because you are subscribed to the Google Groups "headless-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev+unsubscribe@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/cf2b1738-4aa5-4199-92fc-0c825af1de6f%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "headless-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev+unsubscribe@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/52b30bb1-83b2-4097-9c62-9b7c1c2e2362%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "headless-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev+unsubscribe@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/cf2b1738-4aa5-4199-92fc-0c825af1de6f%40chromium.org.
Hey guys,I was trying to use this new awesome `Network.setRequestInterceptionEnabled` — but found out it is only enabled in `--headless` mode.Is there any way/plans on making it available in regular versions as well (maybe via a separate cli flag?)
--
You received this message because you are subscribed to the Google Groups "headless-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev+unsubscribe@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/76ece097-9393-49dd-a3c9-ccfb1e5cfc00%40chromium.org.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev...@chromium.org.
To post to this group, send email to headle...@chromium.org.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev+unsubscribe@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/3227bd22-eb90-4d9f-9e8e-0ee08109cdfb%40chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/3227bd22-eb90-4d9f-9e8e-0ee08109cdfb%40chromium.org.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev+unsubscribe@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/e449d385-a491-4587-b93a-5894008d0697%40chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/e449d385-a491-4587-b93a-5894008d0697%40chromium.org.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev+unsubscribe@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/6138d1f6-9efb-4562-94bb-d0aed8bcb7d0%40chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/6138d1f6-9efb-4562-94bb-d0aed8bcb7d0%40chromium.org.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev+unsubscribe@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/2f5248eb-e2ca-4210-8175-b023852a8142%40chromium.org.
Network.responseReceived((response) => {
const body = client.Network.getResponseBody({requestId: response.requestId})
// cache the body
})
Hi,Is it possible to use this feature for having an aggressive cache? My use case is to be able to "reload" a page very efficiently by caching all the initial requests it made. Basically:- load a page- intercept and store all the requests- do some automated testings that require at some point to reload the page (a.k.a. "resetting" the page to the initial state)- reload the page fast by intercepting all the reloading requests and serving same the same previous content to avoid (almost) any network calls
My problem is that Network.requestIntercepted requires a rawResponse which is the full response (with status line, headers and body) but I'm only able to get the first response bodies usingNetwork.responseReceived((response) => {
const body = client.Network.getResponseBody({requestId: response.requestId})
// cache the body
})But reconstructing the full response has been unsuccessful so far (I tried take the base64 encoding into account, and adding the response headers and status).
So my questions are:- is there some other way I missed to get the full response of a request?
- can my method work or I am completely wrong? If so, would you see another strategy to "reset" the page to the initial loading in an efficient way (browser caching is not enough, I need to avoid network calls)?
--
You received this message because you are subscribed to the Google Groups "headless-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev+unsubscribe@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/02b93892-baf6-48b5-a54e-711fee279e5b%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "headless-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev+unsubscribe@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/3e3576ed-6290-4671-81d9-c05e9699627b%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "headless-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev+unsubscribe@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/fc261736-8da0-44c6-8424-67f589de0eb9%40chromium.org.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev...@chromium.org.
To post to this group, send email to headle...@chromium.org.