aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-12-04 11:57:26 +0100
committerKim Alvefur <zash@zash.se>2016-12-04 11:57:26 +0100
commit1ec77e632e546e8fefe7cb7fb87f9d3c5bfdfbe0 (patch)
treed29d8ae9c323d31527aaa3ab471606171ace1f23 /plugins
parentf758fdb4d600d74251e6c10cff8116c40fce6771 (diff)
downloadprosody-1ec77e632e546e8fefe7cb7fb87f9d3c5bfdfbe0.tar.gz
prosody-1ec77e632e546e8fefe7cb7fb87f9d3c5bfdfbe0.zip
mod_websocket: Use contains_token from util.http for checking if the requested WebSocket sub-protocols include XMPP
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_websocket.lua6
1 files changed, 2 insertions, 4 deletions
diff --git a/plugins/mod_websocket.lua b/plugins/mod_websocket.lua
index 26f4c124..66e214fd 100644
--- a/plugins/mod_websocket.lua
+++ b/plugins/mod_websocket.lua
@@ -14,6 +14,7 @@ local sha1 = require "util.hashes".sha1;
local base64 = require "util.encodings".base64.encode;
local st = require "util.stanza";
local parse_xml = require "util.xml".parse;
+local contains_token = require "util.http".contains_token;
local portmanager = require "core.portmanager";
local sm_destroy_session = require"core.sessionmanager".destroy_session;
local log = module._log;
@@ -142,10 +143,7 @@ function handle_request(event)
</body></html>]];
end
- local wants_xmpp = false;
- (request.headers.sec_websocket_protocol or ""):gsub("([^,]*),?", function (proto)
- if proto == "xmpp" then wants_xmpp = true; end
- end);
+ local wants_xmpp = contains_token(request.headers.sec_websocket_protocol or "", "xmpp");
if not wants_xmpp then
module:log("debug", "Client didn't want to talk XMPP, list of protocols was %s", request.headers.sec_websocket_protocol or "(empty)");