-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check minsize when writing first byte #91
base: master
Are you sure you want to change the base?
Conversation
gzip_test.go
Outdated
@@ -208,6 +208,51 @@ func TestGzipHandlerNoBody(t *testing.T) { | |||
} | |||
} | |||
|
|||
func TestGzipHnalderStream(t *testing.T) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
@@ -166,7 +166,7 @@ func (w *GzipResponseWriter) startGzip() error { | |||
// Initialize and flush the buffer into the gzip response if there are any bytes. | |||
// 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 { |
There was a problem hiding this comment.
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.
I removed the invalid fix, but left the test case up there showing the issue we are running into |
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