aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_websocket.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-02-21 06:20:55 +0100
committerKim Alvefur <zash@zash.se>2021-02-21 06:20:55 +0100
commit49d6a7a91f9af9009db2279736d842603d2f1106 (patch)
tree32a27ad68b5d87bbcbdd719a1c6d3baf4059208a /plugins/mod_websocket.lua
parentd18348b578ab72b09840fedfc58d7b6de5fb53b5 (diff)
downloadprosody-49d6a7a91f9af9009db2279736d842603d2f1106.tar.gz
prosody-49d6a7a91f9af9009db2279736d842603d2f1106.zip
mod_websocket: Use mod_http_errors html template #1172
Same as the prior commit to mod_bosh
Diffstat (limited to 'plugins/mod_websocket.lua')
-rw-r--r--plugins/mod_websocket.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/plugins/mod_websocket.lua b/plugins/mod_websocket.lua
index e70b907d..6946894a 100644
--- a/plugins/mod_websocket.lua
+++ b/plugins/mod_websocket.lua
@@ -135,8 +135,11 @@ local function filter_open_close(data)
return data;
end
+local default_get_response_text = "It works! Now point your WebSocket client to this URL to connect to Prosody."
+local websocket_get_response_text = module:get_option_string("websocket_get_response_text", default_get_response_text)
+
local default_get_response_body = [[<!DOCTYPE html><html><head><title>Websocket</title></head><body>
-<p>It works! Now point your WebSocket client to this URL to connect to Prosody.</p>
+<p>]]..websocket_get_response_text..[[</p>
</body></html>]]
local websocket_get_response_body = module:get_option_string("websocket_get_response_body", default_get_response_body)
@@ -205,9 +208,14 @@ function handle_request(event)
conn.starttls = false; -- Prevent mod_tls from believing starttls can be done
if not request.headers.sec_websocket_key or request.method ~= "GET" then
- response.headers.content_type = "text/html";
- return websocket_get_response_body;
- end
+ return module:fire_event("http-message", {
+ response = event.response;
+ ---
+ title = "Prosody WebSocket endpoint";
+ message = websocket_get_response_text;
+ warning = not (consider_websocket_secure or request.secure) and "This endpoint is not considered secure!" or nil;
+ }) or websocket_get_response_body;
+ end
local wants_xmpp = contains_token(request.headers.sec_websocket_protocol or "", "xmpp");