1

I am trying to port one of our services to Aleph. The service uses a web socket server (currently runs on http-kit). One of the things I require is the ability to add some custom http headers in the response during the websocket Upgrade process. Do you see a way I could do that?

To elaborate, I need to inspect the Sec-WebSocket-Extensions header value from the client request, and based on that add a response header during the upgrade process. And similarly need to check the Sec-WebSocket-Protocol header in the request, and add the same back to the response if the protocol is what I expect.

msj
  • 143
  • 1
  • 6

1 Answers1

2

Both websocket-connection & websocket-client accepts a :headers keywords parameter. The documentation is here.

muhuk
  • 15,777
  • 9
  • 59
  • 98
  • 1
    I am aware of that. But it does not say anything beyond 'the headers will be included in the handshake'. I want to be able to inspect the values of a couple of request headers during the upgrade, and based on those values, add some headers back to the response. Does the above :headers keyword you mentioned do the job of simply including whatever headers I pass (during the connect) in the response? – msj Mar 21 '16 at 07:22
  • I can inspect the headers prior to calling the websocket-connection fn, and stuff my custom response headers in the :headers keyword. Would that mean that Aleph would pass back those headers to the client during the handshake? @muhuk – msj Mar 21 '16 at 07:27