Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome DevTools Protocol - intercepting and modifying websocket requests

I'm trying to use the Chrome DevTools Protocol (CDP) to intercept web requests and modify them.

The problem is that I need to modify the headers of a WebSocket request. Is this possible?

I can modify the headers of "normal" requests easily by first sending messages:

Network.enable
Network.setRequestInterception

and then listening for the Network.requestIntercepted message and replying with an appropriate Network.continueInterceptedRequest message.

However, Network.requestIntercepted does not get called for WebSockets. I can listen for Network.webSocketWillSendHandshakeRequest but this only lets me read the request, I don't see any way to modify it.

Is there a way to do this, or is this impossible at the moment?

like image 390
Master_T Avatar asked Sep 09 '19 15:09

Master_T


People also ask

What is Chrome DevTools protocol?

The Chrome DevTools Protocol provides APIs to instrument, inspect, debug, and profile Chromium-based browsers. The Chrome DevTools Protocol is the foundation for the Microsoft Edge DevTools. Use the Chrome DevTools Protocol for features that aren't implemented in the WebView2 platform.


1 Answers

After further testing of all possible combinations, I came to the conclusion that this cannot be done, unfortunately.

If I'm wrong, feel free to correct me and I'll accept your answer and delete this one.

like image 169
Master_T Avatar answered Oct 14 '22 18:10

Master_T