equal
deleted
inserted
replaced
12 local add_filter = require "util.filters".add_filter; |
12 local add_filter = require "util.filters".add_filter; |
13 local sha1 = require "util.hashes".sha1; |
13 local sha1 = require "util.hashes".sha1; |
14 local base64 = require "util.encodings".base64.encode; |
14 local base64 = require "util.encodings".base64.encode; |
15 local st = require "util.stanza"; |
15 local st = require "util.stanza"; |
16 local parse_xml = require "util.xml".parse; |
16 local parse_xml = require "util.xml".parse; |
|
17 local contains_token = require "util.http".contains_token; |
17 local portmanager = require "core.portmanager"; |
18 local portmanager = require "core.portmanager"; |
18 local sm_destroy_session = require"core.sessionmanager".destroy_session; |
19 local sm_destroy_session = require"core.sessionmanager".destroy_session; |
19 local log = module._log; |
20 local log = module._log; |
20 |
21 |
21 local websocket_frames = require"net.websocket.frames"; |
22 local websocket_frames = require"net.websocket.frames"; |
140 return [[<!DOCTYPE html><html><head><title>Websocket</title></head><body> |
141 return [[<!DOCTYPE html><html><head><title>Websocket</title></head><body> |
141 <p>It works! Now point your WebSocket client to this URL to connect to Prosody.</p> |
142 <p>It works! Now point your WebSocket client to this URL to connect to Prosody.</p> |
142 </body></html>]]; |
143 </body></html>]]; |
143 end |
144 end |
144 |
145 |
145 local wants_xmpp = false; |
146 local wants_xmpp = contains_token(request.headers.sec_websocket_protocol or "", "xmpp"); |
146 (request.headers.sec_websocket_protocol or ""):gsub("([^,]*),?", function (proto) |
|
147 if proto == "xmpp" then wants_xmpp = true; end |
|
148 end); |
|
149 |
147 |
150 if not wants_xmpp then |
148 if not wants_xmpp then |
151 module:log("debug", "Client didn't want to talk XMPP, list of protocols was %s", request.headers.sec_websocket_protocol or "(empty)"); |
149 module:log("debug", "Client didn't want to talk XMPP, list of protocols was %s", request.headers.sec_websocket_protocol or "(empty)"); |
152 return 501; |
150 return 501; |
153 end |
151 end |