Hello
As discussed in the Prosody MUC, here is a patch to add config settings
for overriding the default GET response body for the BOSH and websocket
modules.
JC
--
You received this message because you are subscribed to the Google Groups
"prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to prosody-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/prosody-dev/7eb2f626-c0ea-8c65-0a7e-208a7aeed11c%40opkode.com.
# HG changeset patch
# User JC Brand <j...@opkode.com>
# Date 1585318485 -3600
# Fri Mar 27 15:14:45 2020 +0100
# Branch 0.11
# Node ID 48f8e56f7b160717c7e07a9470345c4a5d7a0bbc
# Parent 3fce670e073300889a08c354e26287d6d4d2a111
bosh, websocket: Allow HTTP GET response body to be overridden
diff -r 3fce670e0733 -r 48f8e56f7b16 plugins/mod_bosh.lua
--- a/plugins/mod_bosh.lua Sun Mar 22 21:05:59 2020 +0100
+++ b/plugins/mod_bosh.lua Fri Mar 27 15:14:45 2020 +0100
@@ -495,14 +495,16 @@
end
end
+local GET_response_body = [[<html><body>
+ <p>It works! Now point your BOSH client to this URL to connect to
Prosody.</p>
+ <p>For more information see <a
href="https://prosody.im/doc/setting_up_bosh">Prosody: Setting up BOSH</a>.</p>
+ </body></html>]];
+
local GET_response = {
headers = {
content_type = "text/html";
};
- body = [[<html><body>
- <p>It works! Now point your BOSH client to this URL to connect to
Prosody.</p>
- <p>For more information see <a
href="https://prosody.im/doc/setting_up_bosh">Prosody: Setting up BOSH</a>.</p>
- </body></html>]];
+ body = module:get_option_string("http_get_response_body",
GET_response_body);
};
module:depends("http");
diff -r 3fce670e0733 -r 48f8e56f7b16 plugins/mod_websocket.lua
--- a/plugins/mod_websocket.lua Sun Mar 22 21:05:59 2020 +0100
+++ b/plugins/mod_websocket.lua Fri Mar 27 15:14:45 2020 +0100
@@ -138,6 +138,12 @@
return data;
end
+
+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>
+</body></html>]]
+local websocket_get_response_body =
module:get_option_string("websocket_get_response_body",
default_get_response_body)
+
function handle_request(event)
local request, response = event.request, event.response;
local conn = response.conn;
@@ -146,9 +152,7 @@
if not request.headers.sec_websocket_key then
response.headers.content_type = "text/html";
- return [[<!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>
- </body></html>]];
+ return websocket_get_response_body;
end
local wants_xmpp =
contains_token(request.headers.sec_websocket_protocol or "", "xmpp");