Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
11392:a76493b75dec | 11393:e6122e6a40a0 |
---|---|
133 end | 133 end |
134 | 134 |
135 return data; | 135 return data; |
136 end | 136 end |
137 | 137 |
138 local default_get_response_text = "It works! Now point your WebSocket client to this URL to connect to Prosody." | |
139 local websocket_get_response_text = module:get_option_string("websocket_get_response_text", default_get_response_text) | |
140 | |
138 local default_get_response_body = [[<!DOCTYPE html><html><head><title>Websocket</title></head><body> | 141 local default_get_response_body = [[<!DOCTYPE html><html><head><title>Websocket</title></head><body> |
139 <p>It works! Now point your WebSocket client to this URL to connect to Prosody.</p> | 142 <p>]]..websocket_get_response_text..[[</p> |
140 </body></html>]] | 143 </body></html>]] |
141 local websocket_get_response_body = module:get_option_string("websocket_get_response_body", default_get_response_body) | 144 local websocket_get_response_body = module:get_option_string("websocket_get_response_body", default_get_response_body) |
142 | 145 |
143 local function validate_frame(frame, max_length) | 146 local function validate_frame(frame, max_length) |
144 local opcode, length = frame.opcode, frame.length; | 147 local opcode, length = frame.opcode, frame.length; |
203 local conn = response.conn; | 206 local conn = response.conn; |
204 | 207 |
205 conn.starttls = false; -- Prevent mod_tls from believing starttls can be done | 208 conn.starttls = false; -- Prevent mod_tls from believing starttls can be done |
206 | 209 |
207 if not request.headers.sec_websocket_key or request.method ~= "GET" then | 210 if not request.headers.sec_websocket_key or request.method ~= "GET" then |
208 response.headers.content_type = "text/html"; | 211 return module:fire_event("http-message", { |
209 return websocket_get_response_body; | 212 response = event.response; |
210 end | 213 --- |
214 title = "Prosody WebSocket endpoint"; | |
215 message = websocket_get_response_text; | |
216 warning = not (consider_websocket_secure or request.secure) and "This endpoint is not considered secure!" or nil; | |
217 }) or websocket_get_response_body; | |
218 end | |
211 | 219 |
212 local wants_xmpp = contains_token(request.headers.sec_websocket_protocol or "", "xmpp"); | 220 local wants_xmpp = contains_token(request.headers.sec_websocket_protocol or "", "xmpp"); |
213 | 221 |
214 if not wants_xmpp then | 222 if not wants_xmpp then |
215 module:log("debug", "Client didn't want to talk XMPP, list of protocols was %s", request.headers.sec_websocket_protocol or "(empty)"); | 223 module:log("debug", "Client didn't want to talk XMPP, list of protocols was %s", request.headers.sec_websocket_protocol or "(empty)"); |