Is your feature request related to a problem? Please describe.
I'm using WebSocketKit on both the Vapor server-side, and from a client-side. For my own custom authentication system, I'd like to send something in the initial request headers from the client (already possible), then do some stuff with it to generate an authentication token on the server-side (already possible, server-side shouldUpgrade closure), and then send the token back in the response headers (already possible, server-side shouldUpgrade closure). The problem is the client being able to receive that. As of now, WebSocketKit doesn't give the client-side connecting functions access to the Request or headers in the upgrading Request from the server.
I even did a test of my workflow and put a breakpoint there to inspect req, and it had the header I was looking for.
Describe the solution you'd like
Is it possible to add a req or headers parameter to the onUpgrade closure? Or a way to access it from theWebSocket` instance, like a new property on it?
Describe alternatives you've considered
Alternatively, I can set up my workflow to be sent via standard message as soon as the connection is upgraded (which is probably what I'll do until this is resolved), but I love for this to be integrated into the connection setup.
Is your feature request related to a problem? Please describe. I'm using WebSocketKit on both the Vapor server-side, and from a client-side. For my own custom authentication system, I'd like to send something in the initial request headers from the client (already possible), then do some stuff with it to generate an authentication token on the server-side (already possible, server-side
shouldUpgrade
closure), and then send the token back in the response headers (already possible, server-sideshouldUpgrade
closure). The problem is the client being able to receive that. As of now, WebSocketKit doesn't give the client-side connecting functions access to theRequest
or headers in the upgradingRequest
from the server.I found where it's accessed in the package code, but it's not made accessible to the client: https://github.com/vapor/websocket-kit/blob/4232d34efa49f633ba61afde365d3896fc7f8740/Sources/WebSocketKit/WebSocketClient.swift#L137-L143
I even did a test of my workflow and put a breakpoint there to inspect
req
, and it had the header I was looking for.Describe the solution you'd like Is it possible to add a
req
orheaders
parameter to theonUpgrade closure? Or a way to access it from the
WebSocket` instance, like a new property on it?Describe alternatives you've considered Alternatively, I can set up my workflow to be sent via standard message as soon as the connection is upgraded (which is probably what I'll do until this is resolved), but I love for this to be integrated into the connection setup.
Thanks in advance for any help with this!