mirror of
https://github.com/nanmu42/gzip.git
synced 2025-12-24 11:51:04 +08:00
Do not change response code after 204
This commit is contained in:
@@ -118,6 +118,7 @@ func (w *writerWrapper) Write(data []byte) (int, error) {
|
||||
}
|
||||
|
||||
if !w.shouldCompress {
|
||||
w.WriteHeaderNow()
|
||||
return w.OriginWriter.Write(data)
|
||||
}
|
||||
if w.bodyBigEnough {
|
||||
|
||||
@@ -389,3 +389,12 @@ func Test_writerWrapper_Write_content_type_no_sniff(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, bigPayload, body)
|
||||
}
|
||||
|
||||
func Test_writeWrapper_does_not_change_status_code_after_204(t *testing.T) {
|
||||
wrapper, recorder := newWrapper()
|
||||
|
||||
wrapper.WriteHeader(http.StatusNoContent)
|
||||
_, _ = wrapper.Write([]byte("something"))
|
||||
|
||||
assert.Equal(t, http.StatusNoContent, recorder.Code)
|
||||
}
|
||||
Reference in New Issue
Block a user