Added ability to intercept and manipulate web socket messages#991
Open
RoscoP wants to merge 2 commits intohttp-party:masterfrom
Open
Added ability to intercept and manipulate web socket messages#991RoscoP wants to merge 2 commits intohttp-party:masterfrom
RoscoP wants to merge 2 commits intohttp-party:masterfrom
Conversation
|
Any chance that this will be merged some day? |
58 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I offer this PR up in case this functionality is desired for node-http-proxy - I needed this ability, but couldn't find it anywhere and thought someone else might find it useful. Thanks for the solid code.
I've isolated this ability away from the normal proxy behavior. If you set
wsInterceptMessagestotruein the options then it will intercept and relay websocket messages.In options:
wsOnMessageToServer- Is a function called when a message is intercepted on its way to the server. It takes two arguments: data is a websocket message in a Buffer class, and flags describe the message (compressed, binary, etc - from the websocket ws/lib/Receiver and Sender classes. This function is expected to return a buffer that is to be used for the websocket message. Ifnullis returned, the message is consumed and nothing will be forwarded along the websocket proxy.wsOnMessageToClient- Is a function called when a message is intercepted on its way to the client. It also takes the same arguments aswsOnMessageToServerEvents:
message_toserver- Emitted on message to server, can be used in place of the functions if you only wish to monitor and not modify the messages.message_toclient- Same as above for client.websocket_connected- Emitted when websocket interception setup is complete.