Skip to content

Conversation

@drewbailey
Copy link

Fix bug where writing and flushing a zero byte write would cause startGzip() to run but not write, and then on subsequent writes call startPlain, resulting in invalid header errors

gzip_test.go Outdated
}
}

func TestGzipHnalderStream(t *testing.T) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean write TestGzipHandlerStream instead of TestGzipHnalderStream

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops yep! Also I’m not confident in the fix but the test case reproduces the issue at hand.

Startgzip gets called but not init then subsequently startPlain gets called and then errors

gzip.go Outdated
// If there aren't any, we shouldn't initialize it yet because on Close it will
// write the gzip header even if nothing was ever written.
if len(w.buf) > 0 {
if len(w.buf) >= w.minSize {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to introduce another issue found in the failing test case due to the reason previously mentioned. This is preventing w.init() from being called. Also, the following conditional check len(w.buf) >= w.minSize is already made in the write function.

@drewbailey
Copy link
Author

I removed the invalid fix, but left the test case up there showing the issue we are running into

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants