I would like to use websockets with a Jetty-Server (Version 8.1.9) only if the websocket-version is 13 aka RFC 6455 is available. If its not available a http-fallback-solution will be used.
[random Browser Javascript] <--websocket v13 only--> [Jetty Server Java]
The websocket-protocol-version is stored inside the WebSocket handshake request:
GET /mychat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Protocol: chat
Sec-WebSocket-Version: 13
Origin: http://example.com
Now I'd like to have something like this in javascript:
if (window.WebSocket)
{
// browser supports websockets
if (bla.websocketversion != 13)
{
// wrong websocket version
// use fallback connection
}
else
{
// use websockets
}
}
else
{
// use fallback connection
}
If I connect to the Jetty-Server using a iPad with Safari 5.0.2 (which appearently uses an older websocket protocol) I get a Warning: WARN:oejw.WebSocketFactory:Unsupported Websocket version: 2147483647
I could not find a way to get the access or change the handshake request in Javascript. Is it impossible? Any workarounds for this?