Mercurial > prosody-modules
diff mod_websocket/mod_websocket.lua @ 1025:b56a9aa171b3
mod_websocket: Fix length calculation
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Thu, 30 May 2013 22:48:19 +0200 |
parents | 8eba9d4809d2 |
children | e254cf49e14d |
line wrap: on
line diff
--- 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;