# HG changeset patch # User Florian Zeitz # Date 1369946899 -7200 # Node ID b56a9aa171b341c74e684011aca6da9649b9f7f9 # Parent d7655e634c306980c47a78359fb41987e5be2b2c mod_websocket: Fix length calculation diff -r d7655e634c30 -r b56a9aa171b3 mod_websocket/mod_websocket.lua --- a/mod_websocket/mod_websocket.lua Wed May 29 11:37:42 2013 +0200 +++ b/mod_websocket/mod_websocket.lua Thu May 30 22:48:19 2013 +0200 @@ -107,10 +107,13 @@ result = result .. string.char(126); result = result .. string.char(rshift(length, 8)) .. string.char(length%0x100); else -- 8-byte length + local length_bytes = {}; result = result .. string.char(127); - for i = 7, 0, -1 do - result = result .. string.char(rshift(length, 8*i) % 0x100); + for i = 8, 1, -1 do + length_bytes[i] = string.char(length % 0x100); + length = rshift(length, 8); end + result = result .. table.concat(length_bytes, ""); end result = result .. data;