Changeset

844:a0987c0e4e1d

mod_websocket: Check whether the xmpp sub-protocol was requested
author Florian Zeitz <florob@babelmonkeys.de>
date Fri, 05 Oct 2012 19:44:23 +0200
parents 843:cdc67f4efde2
children 845:1c14edca74a4
files mod_websocket/mod_websocket.lua
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_websocket/mod_websocket.lua	Fri Oct 05 19:34:53 2012 +0200
+++ b/mod_websocket/mod_websocket.lua	Fri Oct 05 19:44:23 2012 +0200
@@ -446,7 +446,14 @@
 			</body></html>]];
 	end
 
-	-- TODO: Handle requested subprotocols
+	local wants_xmpp = false;
+	(request.headers.sec_websocket_protocol or ""):gsub("([^,]*),?", function (proto)
+		if proto == "xmpp" then wants_xmpp = true; end
+	end);
+
+	if not wants_xmpp then
+		return 501;
+	end
 
 	response.conn:setlistener(listener);
 	response.status = "101 Switching Protocols";