Skip to content

Commit

Permalink
Remove returns http-status bad request
Browse files Browse the repository at this point in the history
  • Loading branch information
mirecl committed Sep 10, 2024
1 parent 7fa5377 commit 841069f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
7 changes: 2 additions & 5 deletions gzhttp/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,9 @@ func NewWrapper(opts ...option) (func(http.Handler) http.HandlerFunc, error) {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Add(vary, acceptEncoding)
if contentGzip(r) {
readerGzipBody, err := gzip.NewReader(r.Body)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
if readerGzipBody, err := gzip.NewReader(r.Body); err == nil {
r.Body = io.NopCloser(readerGzipBody)
}
r.Body = io.NopCloser(readerGzipBody)
}

if acceptsGzip(r) {
Expand Down
10 changes: 0 additions & 10 deletions gzhttp/compress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,6 @@ func TestMustNewGzipHandler(t *testing.T) {

assertEqual(t, http.DetectContentType([]byte(testBody)), res3.Header().Get("Content-Type"))

// send not compress request body

req4, _ := http.NewRequest("POST", "/whatever", bytes.NewBuffer(testBody))
req4.Header.Set("Content-Encoding", "gzip")
resp4 := httptest.NewRecorder()
handler.ServeHTTP(resp4, req4)
res4 := resp4.Result()

assertEqual(t, 400, res4.StatusCode)

// send compress request body

var b bytes.Buffer
Expand Down

0 comments on commit 841069f

Please sign in to comment.