diff --git a/httpbin/handlers.go b/httpbin/handlers.go index e1197660d07a0b28e2ef6bb9df63f5149c13a67a..2583cf9617367307c55260a62cfc593876277fa0 100644 --- a/httpbin/handlers.go +++ b/httpbin/handlers.go @@ -2,8 +2,8 @@ package httpbin import ( "bytes" - "compress/flate" "compress/gzip" + "compress/zlib" "encoding/json" "fmt" "math/rand" @@ -109,7 +109,7 @@ func (h *HTTPBin) Deflate(w http.ResponseWriter, r *http.Request) { body, _ := json.Marshal(resp) buf := &bytes.Buffer{} - w2, _ := flate.NewWriter(buf, flate.DefaultCompression) + w2 := zlib.NewWriter(buf) w2.Write(body) w2.Close() diff --git a/httpbin/handlers_test.go b/httpbin/handlers_test.go index 47ed24f766ae76489c572230b00c33a09d063d3a..c8313aed2f9eccf0cc26c7517088d9309de199f2 100644 --- a/httpbin/handlers_test.go +++ b/httpbin/handlers_test.go @@ -3,8 +3,8 @@ package httpbin import ( "bufio" "bytes" - "compress/flate" "compress/gzip" + "compress/zlib" "encoding/json" "fmt" "io/ioutil" @@ -1261,7 +1261,10 @@ func TestDeflate(t *testing.T) { t.Fatal(err) } - reader := flate.NewReader(w.Body) + reader, err := zlib.NewReader(w.Body) + if err != nil { + t.Fatal(err) + } body, err := ioutil.ReadAll(reader) if err != nil { t.Fatal(err)