-
I'm trying to pass headers from the upgrade callback to the WebSocket object, so that I can access those headers on websocket "open" and "message" callbacks. For example, let's say I want to access a header called {
upgrade: (res, req, context) => {
context.mySuperHeader = req.getHeader('super-header');
res.upgrade({
url: req.getUrl()
},
req.getHeader('sec-websocket-key'),
req.getHeader('sec-websocket-protocol'),
req.getHeader('sec-websocket-extensions'),
context);
},
message: (ws, message, isBinary) => {
ws.context.mySuperHeader // <---------------------------
},
} I'm sorry if it is a stupid questions, I just cannot find a documented way to do it. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
I see in C++ version there is If something like that was in Node version that would solve it, but I cannot find one. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately I'm not a C++ developer, but maybe something like this could be a patch? |
Beta Was this translation helpful? Give feedback.
-
In addition to having |
Beta Was this translation helpful? Give feedback.
-
nvm, found the right way of doing it: #339 (comment) |
Beta Was this translation helpful? Give feedback.
-
There are two examples |
Beta Was this translation helpful? Give feedback.
There are two examples