You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I find it confusing that the gzip.Writer.Flush() method doesn't actually flush the compressed data to the underlying buffer.
I'm running: go version go1.6.1 darwin/amd64
I was expecting the number of written bytes after flushing and after closing the writer to be the same but that is not the case.
Also calling Flush() multiple times results in more data being written to the underlying buffer than it was written to the gzip writer – https://play.golang.org/p/ochlIkK6KS – is this expected behavior or is it a bug?
The text was updated successfully, but these errors were encountered:
adg
changed the title
compress/gzip Flush doesn't actually flush the writer
compress/gzip: document that Flush writes additional data, even if there is no more compressed data to write
Jun 15, 2016
Thank you for the quick response! Yeah, better documentation would be very useful as I would expect Flush() to behave differently and probably I'm not alone.
adg
added
the
NeedsFix
The path to resolution is known, but the work has not been done.
label
Jun 15, 2016
What @adg said is correct. The behavior of gzip flushing is necessary for the correct operation of some network protocols. Not only does Flush ensure all buffered data has been flushed to the wire, it also writes a special synchronization message (really just an empty raw block) for the recipient to know that such a flushing event had occurred. There's an entire unit test in compress/flate just to lock this behavior in.
Just to confirm though, Flush does indeed ensure all the buffered data has hit the underlying io.Writer.
I find it confusing that the
gzip.Writer.Flush()
method doesn't actually flush the compressed data to the underlying buffer.I'm running:
go version go1.6.1 darwin/amd64
Here is the code: https://play.golang.org/p/zXIh2ZL5Cs
I was expecting the number of written bytes after flushing and after closing the writer to be the same but that is not the case.
Also calling
Flush()
multiple times results in more data being written to the underlying buffer than it was written to the gzip writer – https://play.golang.org/p/ochlIkK6KS – is this expected behavior or is it a bug?The text was updated successfully, but these errors were encountered: