guzba / zippy

Pure Nim implementation of deflate, zlib, gzip and zip.
MIT License
246 stars 29 forks source link

Add inflation support [streams] #15

Closed krisppurg closed 1 year ago

krisppurg commented 3 years ago

Since zip and this library doesn't support reusing the same z_stream context for multiple messages.

In my own discord library, I would like to implement some transport compression which neither zip or zippy have this functionality of creating a zlib inflation context to run chunks through. (https://discord.com/developers/docs/topics/gateway#transport-compression-transport-compression-example)

krisppurg commented 3 years ago

any news?

guzba commented 2 years ago

Hello, sorry I did not reply here before. It appears from glancing at the docs that you should be able to just call uncompress from zippy on each zlib chunk from Discord. Looking now, it also appears you've maybe got it working: https://github.com/krisppurg/dimscord/blob/ac2c7a04538207400efd526a1214afc794bff9a3/dimscord/gateway.nim#L452

Let me know if this is working or if there's still trouble.

krisppurg commented 2 years ago

That is there for a placeholder (it's temporary). And the commented code below the line is where I try to attempt to make it work using the example code on the docs as a reference. In other words the line you gave me is only for payload type compression, but I'm trying to implement zlib stream compression (the commented code below). The line won't work for zlib stream type compression, but rather on payload compression.

guzba commented 2 years ago

Ah ok, I understand what's up here. Hm, the issue here is it requires me to implement a zippy stream api, and also implement it exactly the same way as zlib does to be compatible. That may be the best way, who knows, I have not given it any thought. Will keep this issue open for future updates to this.

krisppurg commented 1 year ago

Ah ok, I understand what's up here. Hm, the issue here is it requires me to implement a zippy stream api, and also implement it exactly the same way as zlib does to be compatible. That may be the best way, who knows, I have not given it any thought. Will keep this issue open for future updates to this.

any updates?

guzba commented 1 year ago

Hello, sorry to say, no I don't have any update. I have no need for this myself and would basically only be writing it to enable Discord stream compression. Which is cool but not exactly a huge deal. Given all the other things I'm working on, this is unlikely to get worked on any time soon so I'm going to close this issue.