Is there a way to gzip compress data in Lua in a similar manner to PostAsync?
I’m keen to gzip my data prior to posting it, as having the compressed string gives me more options for encrypting the data,
Has anyone had any luck performing this in Lua?
Thanks for your message.
What I’m talking about is obtaining the compressing outside of PostAsyc, giving me the compressed string.
This would give me a lot more flexibility in how I post and authenticate my data.
I imagine this isn’t possible to do in Lua however?
XAXA
(XAXA)
March 18, 2018, 1:31pm
#4
Right, my bad.
I would probably use JSONEncode on my table to convert it into JSON, and then use an open-source gzip script to compress it. And then encode the result into Base64.
EDIT: This seems promising: GitHub - Rochet2/lualzw: A relatively fast LZW compression algorithm in pure lua . I’m not sure that the algorithm is gzip, however EDITEDIT: It’s not gzip, sadly.
Huh. looking for a gzip library was harder than I thought.
I suspect that Lua would do a poor job of handling it efficiently.
XAXA
(XAXA)
March 18, 2018, 1:47pm
#6
I found a gzip module. This might help: lua-compress-deflatelua/lmod/compress/deflatelua.lua at master · davidm/lua-compress-deflatelua · GitHub . (edit: nevermind, the interface permits strings)
EDIT: Actually, ignore this. Compression isn’t implemented in that module
I’d say keep your fingers crossed that @zeuxcg follows this up!
Would there be any interest in us exposing some compression utilities, like deflate and/or lz4? We have some seriously fast compressors available in the engine and we use them for various tasks, like compressing file data, network traffic, etc.
2 Likes
Osyris
(Osyris)
March 18, 2018, 6:17pm
#8
Also keep in mind, if you do compress your data in Lua, I don’t think you’ll be able to use PostAsync due to the fact that you cannot set the gzip header (to indicate to the server that your data is compressed)
1 Like