Software /
code /
prosody
Diff
plugins/mod_websocket.lua @ 11393:e6122e6a40a0
mod_websocket: Use mod_http_errors html template #1172
Same as the prior commit to mod_bosh
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 21 Feb 2021 06:20:55 +0100 |
parent | 11384:f9edf26c66fc |
child | 11560:3bbb1af92514 |
line wrap: on
line diff
--- a/plugins/mod_websocket.lua Sun Feb 21 06:18:22 2021 +0100 +++ b/plugins/mod_websocket.lua Sun Feb 21 06:20:55 2021 +0100 @@ -135,8 +135,11 @@ 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 @@ 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");