Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • N node-http-proxy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 482
    • Issues 482
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 102
    • Merge requests 102
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • http ... PARTY!
  • node-http-proxy
  • Merge requests
  • !991

Added ability to intercept and manipulate web socket messages

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/RoscoP/websocket-intercept-msg into master Apr 19, 2016
  • Overview 1
  • Commits 2
  • Pipelines 1
  • Changes 1

Created by: RoscoP

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 wsInterceptMessages to true in 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. If null is 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 as wsOnMessageToServer

Events: 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.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/RoscoP/websocket-intercept-msg