Software /
code /
prosody-modules
Changeset
689:4d21bd5dde49
mod_websocket: Be nice to non-websocket clients
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Sun, 27 May 2012 17:53:52 +0200 |
parents | 688:e87678a52720 |
children | 690:5acc203972f3 |
files | mod_websocket/mod_websocket.lua |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_websocket/mod_websocket.lua Sun May 27 17:17:52 2012 +0200 +++ b/mod_websocket/mod_websocket.lua Sun May 27 17:53:52 2012 +0200 @@ -315,7 +315,12 @@ function handle_request(event, path) local request, response = event.request, event.response; - -- Add sanity checks + 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>]]; + end response.conn:setlistener(listener); response.status = "101 Switching Protocols";