@@ -14,7 +14,6 @@ import (
14
14
"flag"
15
15
"fmt"
16
16
"io"
17
- "io/ioutil"
18
17
"log"
19
18
"net"
20
19
"net/http"
@@ -38,7 +37,7 @@ func stderrv() io.Writer {
38
37
return os .Stderr
39
38
}
40
39
41
- return ioutil .Discard
40
+ return io .Discard
42
41
}
43
42
44
43
type safeBuffer struct {
@@ -896,7 +895,7 @@ func testBodyContents(t *testing.T, wantContentLength int64, wantBody string, wr
896
895
if r .ContentLength != wantContentLength {
897
896
t .Errorf ("ContentLength = %v; want %d" , r .ContentLength , wantContentLength )
898
897
}
899
- all , err := ioutil .ReadAll (r .Body )
898
+ all , err := io .ReadAll (r .Body )
900
899
if err != nil {
901
900
t .Fatal (err )
902
901
}
@@ -917,7 +916,7 @@ func testBodyContentsFail(t *testing.T, wantContentLength int64, wantReadError s
917
916
if r .ContentLength != wantContentLength {
918
917
t .Errorf ("ContentLength = %v; want %d" , r .ContentLength , wantContentLength )
919
918
}
920
- all , err := ioutil .ReadAll (r .Body )
919
+ all , err := io .ReadAll (r .Body )
921
920
if err == nil {
922
921
t .Fatalf ("expected an error (%q) reading from the body. Successfully read %q instead." ,
923
922
wantReadError , all )
@@ -2992,7 +2991,7 @@ func TestServerReadsTrailers(t *testing.T) {
2992
2991
if ! reflect .DeepEqual (r .Trailer , wantTrailer ) {
2993
2992
t .Errorf ("initial Trailer = %v; want %v" , r .Trailer , wantTrailer )
2994
2993
}
2995
- slurp , err := ioutil .ReadAll (r .Body )
2994
+ slurp , err := io .ReadAll (r .Body )
2996
2995
if string (slurp ) != testBody {
2997
2996
t .Errorf ("read body %q; want %q" , slurp , testBody )
2998
2997
}
@@ -3188,7 +3187,7 @@ func BenchmarkServerPosts(b *testing.B) {
3188
3187
// Consume the (empty) body from th peer before replying, otherwise
3189
3188
// the server will sometimes (depending on scheduling) send the peer a
3190
3189
// a RST_STREAM with the CANCEL error code.
3191
- if n , err := io .Copy (ioutil .Discard , r .Body ); n != 0 || err != nil {
3190
+ if n , err := io .Copy (io .Discard , r .Body ); n != 0 || err != nil {
3192
3191
b .Errorf ("Copy error; got %v, %v; want 0, nil" , n , err )
3193
3192
}
3194
3193
io .WriteString (w , msg )
@@ -3252,7 +3251,7 @@ func benchmarkServerToClientStream(b *testing.B, newServerOpts ...interface{}) {
3252
3251
// Consume the (empty) body from th peer before replying, otherwise
3253
3252
// the server will sometimes (depending on scheduling) send the peer a
3254
3253
// a RST_STREAM with the CANCEL error code.
3255
- if n , err := io .Copy (ioutil .Discard , r .Body ); n != 0 || err != nil {
3254
+ if n , err := io .Copy (io .Discard , r .Body ); n != 0 || err != nil {
3256
3255
b .Errorf ("Copy error; got %v, %v; want 0, nil" , n , err )
3257
3256
}
3258
3257
for i := 0 ; i < b .N ; i += 1 {
@@ -3533,7 +3532,7 @@ func BenchmarkServer_GetRequest(b *testing.B) {
3533
3532
b .ReportAllocs ()
3534
3533
const msg = "Hello, world."
3535
3534
st := newServerTester (b , func (w http.ResponseWriter , r * http.Request ) {
3536
- n , err := io .Copy (ioutil .Discard , r .Body )
3535
+ n , err := io .Copy (io .Discard , r .Body )
3537
3536
if err != nil || n > 0 {
3538
3537
b .Errorf ("Read %d bytes, error %v; want 0 bytes." , n , err )
3539
3538
}
@@ -3565,7 +3564,7 @@ func BenchmarkServer_PostRequest(b *testing.B) {
3565
3564
b .ReportAllocs ()
3566
3565
const msg = "Hello, world."
3567
3566
st := newServerTester (b , func (w http.ResponseWriter , r * http.Request ) {
3568
- n , err := io .Copy (ioutil .Discard , r .Body )
3567
+ n , err := io .Copy (io .Discard , r .Body )
3569
3568
if err != nil || n > 0 {
3570
3569
b .Errorf ("Read %d bytes, error %v; want 0 bytes." , n , err )
3571
3570
}
@@ -3639,7 +3638,7 @@ func TestServerHandleCustomConn(t *testing.T) {
3639
3638
EndStream : true ,
3640
3639
EndHeaders : true ,
3641
3640
})
3642
- go io .Copy (ioutil .Discard , c2 )
3641
+ go io .Copy (io .Discard , c2 )
3643
3642
<- handlerDone
3644
3643
}()
3645
3644
const testString = "my custom ConnectionState"
@@ -4001,7 +4000,7 @@ func TestIssue20704Race(t *testing.T) {
4001
4000
4002
4001
func TestServer_Rejects_TooSmall (t * testing.T ) {
4003
4002
testServerResponse (t , func (w http.ResponseWriter , r * http.Request ) error {
4004
- ioutil .ReadAll (r .Body )
4003
+ io .ReadAll (r .Body )
4005
4004
return nil
4006
4005
}, func (st * serverTester ) {
4007
4006
st .writeHeaders (HeadersFrameParam {
0 commit comments