Add support for accesing headers to WebSocket handshake
During the handshake headers are being sent to server (the same way like in HTTP).
The support should be probably added the through [Java/Groovy] getHeaders() method on WebSocket object.
Here is a sample code usage:
vertx.createHttpServer().websocketHandler { ws ->
if(ws.headers["Authorization"] {
ws.dataHandler { data -> ws.writeTextFrame(data.toString()) }
} else {
ws.reject()
}
}.listen(8080)
I'm also interested in this support. My primary driving force is accessing any and all HttpOnly cookies that the browser sends during the handshake. Because the cookies are HttpOnly there is no way for Javascript to do an attempt via websocket frames. (scripts don't have access to the httponly cookies).
Does it make sense to pass in the headers in the constructor, There is another issue for passing request params too.
DefaultWebSocket(VertxInternal vertx, String path, Map<String, String> headers, ServerConnection wsConn, Runnable connectRunnable) {
If this looks OK then I have this ready,
Ok I just implemented this myself in the end. Thanks anyway.