Software /
code /
prosody-modules
Diff
mod_websocket/mod_websocket.lua @ 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 |
parent | 688:e87678a52720 |
child | 690:5acc203972f3 |
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";