diff --git a/httpbin/handlers_test.go b/httpbin/handlers_test.go index 41b6e5d6e371bd27f24f03096c549d4788ebf4d6..90c75fa839f044f7a306e0a922d723c7d7bc9aba 100644 --- a/httpbin/handlers_test.go +++ b/httpbin/handlers_test.go @@ -9,7 +9,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "log" "math/rand" "mime/multipart" @@ -40,7 +40,7 @@ var app = New( WithDefaultParams(testDefaultParams), WithMaxBodySize(maxBodySize), WithMaxDuration(maxDuration), - WithObserver(StdLogObserver(log.New(ioutil.Discard, "", 0))), + WithObserver(StdLogObserver(log.New(io.Discard, "", 0))), ) var handler = app.Handler() @@ -1489,7 +1489,7 @@ func TestGzip(t *testing.T) { t.Fatalf("error creating gzip reader: %s", err) } - unzippedBody, err := ioutil.ReadAll(gzipReader) + unzippedBody, err := io.ReadAll(gzipReader) if err != nil { t.Fatalf("error reading gzipped body: %s", err) } @@ -1533,7 +1533,7 @@ func TestDeflate(t *testing.T) { if err != nil { t.Fatal(err) } - body, err := ioutil.ReadAll(reader) + body, err := io.ReadAll(reader) if err != nil { t.Fatal(err) } @@ -1805,7 +1805,7 @@ func TestDrip(t *testing.T) { } defer resp.Body.Close() - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) if err != nil { t.Fatalf("error reading response body: %s", err) } @@ -1829,7 +1829,7 @@ func TestDrip(t *testing.T) { } // in this case, the timeout happens while trying to read the body - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err == nil { t.Fatal("expected timeout reading body") } @@ -1892,7 +1892,7 @@ func TestDrip(t *testing.T) { } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { t.Fatalf("error reading response body: %s", err) } diff --git a/httpbin/helpers.go b/httpbin/helpers.go index e715752113848c467bb10e33e4779b95ea7673da..4b15e08db78ca89b5b5a91d6aba23258176ba870 100644 --- a/httpbin/helpers.go +++ b/httpbin/helpers.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "math/rand" "net/http" "net/url" @@ -109,7 +108,7 @@ func parseBody(w http.ResponseWriter, r *http.Request, resp *bodyResponse) error // Always set resp.Data to the incoming request body, in case we don't know // how to handle the content type - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { r.Body.Close() return err @@ -119,7 +118,7 @@ func parseBody(w http.ResponseWriter, r *http.Request, resp *bodyResponse) error // After reading the body to populate resp.Data, we need to re-wrap it in // an io.Reader for further processing below r.Body.Close() - r.Body = ioutil.NopCloser(bytes.NewBuffer(body)) + r.Body = io.NopCloser(bytes.NewBuffer(body)) ct := r.Header.Get("Content-Type") switch {