如何拦截 WebSocket 数据?
How to intercept WebSocket data?
在 Firefox 57 中您可以拦截 body of http requests as well as responses (using filterResponseData)。是否可以对网络套接字执行相同的操作?
我不认为你可以使用API来查看WebSocket通信。
webRequestAPI只适用于WebSocket握手,还是正常的HTTP。但是一旦 HTTP 升级完成,它将不再被 API.
观察到
引用相关bugfix on Chrome:
Support WebSocket in WebRequest API.
This CL makes WebRequest API support intercepting the WebSocket handshake
request. Since the handshake is done by means of an HTTP upgrade request, its
flow fits into HTTP-oriented WebRequest model. Additional restriction applies,
that WS request redirects triggered by extensions are ignored.
Note that WebRequest API does not intercept:
- Individual messages sent over an established WebSocket connection.
- WebSocket closing connection
由于 Mozilla 通常会尝试遵循 Chrome 扩展名,因此我希望 Firefox 的行为应该相同。
在 Firefox 57 中您可以拦截 body of http requests as well as responses (using filterResponseData)。是否可以对网络套接字执行相同的操作?
我不认为你可以使用API来查看WebSocket通信。
webRequestAPI只适用于WebSocket握手,还是正常的HTTP。但是一旦 HTTP 升级完成,它将不再被 API.
观察到引用相关bugfix on Chrome:
Support WebSocket in WebRequest API.
This CL makes WebRequest API support intercepting the WebSocket handshake request. Since the handshake is done by means of an HTTP upgrade request, its flow fits into HTTP-oriented WebRequest model. Additional restriction applies, that WS request redirects triggered by extensions are ignored.
Note that WebRequest API does not intercept:
- Individual messages sent over an established WebSocket connection.
- WebSocket closing connection
由于 Mozilla 通常会尝试遵循 Chrome 扩展名,因此我希望 Firefox 的行为应该相同。