Software / code / prosody
Comparison
plugins/mod_websocket.lua @ 7763:c5ce14539fc4
mod_websocket: Add the base URL of each host module is enabled on to 'cross_domain_websocket'
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 05 Dec 2016 12:23:41 +0100 |
| parent | 7762:2208e6cd0d9f |
| child | 7764:d6b96e42e8e6 |
comparison
equal
deleted
inserted
replaced
| 7762:2208e6cd0d9f | 7763:c5ce14539fc4 |
|---|---|
| 313 ["GET"] = handle_request; | 313 ["GET"] = handle_request; |
| 314 ["GET /"] = handle_request; | 314 ["GET /"] = handle_request; |
| 315 }; | 315 }; |
| 316 }); | 316 }); |
| 317 module:hook("c2s-read-timeout", keepalive, -0.9); | 317 module:hook("c2s-read-timeout", keepalive, -0.9); |
| 318 end | 318 |
| 319 if cross_domain ~= true then | |
| 320 local url = require "socket.url"; | |
| 321 local ws_url = module:http_url("websocket", "xmpp-websocket"); | |
| 322 local url_components = url.parse(ws_url); | |
| 323 -- The 'Origin' consists of the base URL without path | |
| 324 url_components.path = nil; | |
| 325 local this_origin = url.build(url_components); | |
| 326 cross_domain:add(this_origin); | |
| 327 function module.unload() | |
| 328 cross_domain:remove(this_origin); | |
| 329 end | |
| 330 end | |
| 331 end |