In order to create a websocket connection in javascript we can use the websocket api for example:
const socket = new WebSocket('ws://localhost:8080');
then the browser will initiate an handshake via http get request with those headers:
Upgrade: websocket
Connection: Upgrade
and the server response :
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
after that the client and server will have websocket connection opened.
So my question is if it's possible to do the handshake on other methods ? and if it's possible to take care of the handshake via javascript like xhr or something like that?