diff options
author | Devaev Maxim <[email protected]> | 2018-08-11 03:46:42 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-08-11 04:09:54 +0300 |
commit | ba650456aaecef6651e598bbd20cc7d53d7d3f97 (patch) | |
tree | a4ab382a09665ddf500e3b9fba900d296c401b57 /kvmd/web/js/session.js | |
parent | 3d2282f8f9d24f3a7e5bb6772471fe506a7299dd (diff) |
Workaround for Safari + Websockets + basic auth
https://bugs.webkit.org/show_bug.cgi?id=80362
Diffstat (limited to 'kvmd/web/js/session.js')
-rw-r--r-- | kvmd/web/js/session.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/kvmd/web/js/session.js b/kvmd/web/js/session.js index d3bbf91c..5e4a491b 100644 --- a/kvmd/web/js/session.js +++ b/kvmd/web/js/session.js @@ -20,11 +20,19 @@ var session = new function() { }; this.startPoller = function() { - __ws = new WebSocket((location.protocol == "https:" ? "wss" : "ws") + "://" + location.host + "/kvmd/ws"); - __ws.onopen = __wsOpenHandler; - __ws.onmessage = __wsMessageHandler; - __ws.onerror = __wsErrorHandler; - __ws.onclose = __wsCloseHandler; + var http = tools.makeRequest("GET", "/wsauth", function() { + if (http.readyState === 4) { + if (http.status === 200) { + __ws = new WebSocket((location.protocol == "https:" ? "wss" : "ws") + "://" + location.host + "/kvmd/ws"); + __ws.onopen = __wsOpenHandler; + __ws.onmessage = __wsMessageHandler; + __ws.onerror = __wsErrorHandler; + __ws.onclose = __wsCloseHandler; + } else { + __wsCloseHandler(null); + } + } + }); }; var __wsOpenHandler = function(event) { |