I'm trying to decompress messages arriving over websockets that are using 
permessage-deflate.

I've run into a couple of issues using flate. 

Assume: 


buf := new(bytes.Buffer)
flater := flate.NewReader(buf)


Each new websockets message is written into buf and then I call Read on 
flater. It works for 1 or more messages (sometimes several right up until I 
fill the 32k window). Eventually the Read fails and flate says there is a 
corrupt byte before some offset. Even after more data has been written to 
buf, successive reads fail. I presume there's some need to reset the flater 
to a previous state, but Reset hasn't gotten me anywhere.

However, the data decompresses fine if I save the entire stream to a file 
and then deflate the file.

What is the correct way to deflate chunks of data as they become available?

(A past post says to call ReadFull but that does not work in this case).

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to