Master_T
Master_T

Reputation: 7913

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?

Upvotes: 7

Views: 2331

Answers (1)

Master_T
Master_T

Reputation: 7913

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.

Upvotes: 2

Related Questions