# HG changeset patch # User Florian Zeitz # Date 1379458626 -7200 # Node ID bbe278a56b0a6484391cee0de81f041e1c5b9c2b # Parent db4085433e5f262d3870adf4b9040bd998b6e69d mod_websocket: Add consider_websocket_secure option diff -r db4085433e5f -r bbe278a56b0a mod_websocket/mod_websocket.lua --- a/mod_websocket/mod_websocket.lua Tue Sep 17 16:02:33 2013 +0200 +++ b/mod_websocket/mod_websocket.lua Wed Sep 18 00:57:06 2013 +0200 @@ -25,6 +25,7 @@ local s_byte = string.byte; local s_char= string.char; +local consider_websocket_secure = module:get_option_boolean("consider_websocket_secure"); local cross_domain = module:get_option("cross_domain_websocket"); if cross_domain then if cross_domain == true then @@ -240,8 +241,12 @@ conn:setlistener(c2s_listener); c2s_listener.onconnect(conn); + local session = sessions[conn]; + + session.secure = consider_websocket_secure or session.secure; + local frameBuffer = ""; - add_filter(sessions[conn], "bytes/in", function(data) + add_filter(session, "bytes/in", function(data) local cache = {}; frameBuffer = frameBuffer .. data; local frame, length = parse_frame(frameBuffer); @@ -256,7 +261,7 @@ return t_concat(cache, ""); end); - add_filter(sessions[conn], "bytes/out", function(data) + add_filter(session, "bytes/out", function(data) return build_frame({ FIN = true, opcode = 0x01, data = tostring(data)}); end);