Changeset

6455:b6514e691a70

net.websocket: Make data masking configurable
author Florian Zeitz <florob@babelmonkeys.de>
date Fri, 26 Sep 2014 22:12:21 +0200
parents 6448:f799b45cf735
children 6456:a8d9d3eea6f4 6457:ddcb29a35409
files net/websocket.lua net/websocket/frames.lua
diffstat 2 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/net/websocket.lua	Sun Sep 28 03:06:29 2014 +0200
+++ b/net/websocket.lua	Fri Sep 26 22:12:21 2014 +0200
@@ -134,7 +134,7 @@
 		log("debug", "closing WebSocket with code %i: %s" , code , tostring(reason));
 		self.readyState = 2;
 		local handler = self.handler;
-		handler:write(frames.build_close(code, reason));
+		handler:write(frames.build_close(code, reason, true));
 		-- Do not close socket straight away, wait for acknowledgement from server.
 		self.close_timer = timer.add_task(close_timeout, close_timeout_cb, self);
 	elseif self.readyState == 2 then
--- a/net/websocket/frames.lua	Sun Sep 28 03:06:29 2014 +0200
+++ b/net/websocket/frames.lua	Fri Sep 26 22:12:21 2014 +0200
@@ -171,7 +171,7 @@
 	return code, message
 end
 
-local function build_close(code, message)
+local function build_close(code, message, mask)
 	local data = pack_uint16be(code);
 	if message then
 		assert(#message<=123, "Close reason must be <=123 bytes");
@@ -180,7 +180,7 @@
 	return build_frame({
 		opcode = 0x8;
 		FIN = true;
-		MASK = true;
+		MASK = mask;
 		data = data;
 	});
 end