diff options
| author | Russ Cox <rsc@golang.org> | 2020-10-16 00:49:02 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2020-10-20 18:41:18 +0000 |
| commit | 1b09d430678d4a6f73b2443463d11f75851aba8a (patch) | |
| tree | fec040abfc6e1d897f8dcdbb856e77d5bccbb2ca /src/net/http/requestwrite_test.go | |
| parent | cb0a0f52e67f128c6ad69027c9a8c7a5caf58446 (diff) | |
| download | go-1b09d430678d4a6f73b2443463d11f75851aba8a.tar.xz | |
all: update references to symbols moved from io/ioutil to io
The old ioutil references are still valid, but update our code
to reflect best practices and get used to the new locations.
Code compiled with the bootstrap toolchain
(cmd/asm, cmd/dist, cmd/compile, debug/elf)
must remain Go 1.4-compatible and is excluded.
Also excluded vendored code.
For #41190.
Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/263142
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Diffstat (limited to 'src/net/http/requestwrite_test.go')
| -rw-r--r-- | src/net/http/requestwrite_test.go | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/net/http/requestwrite_test.go b/src/net/http/requestwrite_test.go index 9ac6701cfd..1157bdfff9 100644 --- a/src/net/http/requestwrite_test.go +++ b/src/net/http/requestwrite_test.go @@ -10,7 +10,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net" "net/url" "strings" @@ -229,7 +228,7 @@ var reqWriteTests = []reqWriteTest{ ContentLength: 0, // as if unset by user }, - Body: func() io.ReadCloser { return ioutil.NopCloser(io.LimitReader(strings.NewReader("xx"), 0)) }, + Body: func() io.ReadCloser { return io.NopCloser(io.LimitReader(strings.NewReader("xx"), 0)) }, WantWrite: "POST / HTTP/1.1\r\n" + "Host: example.com\r\n" + @@ -281,7 +280,7 @@ var reqWriteTests = []reqWriteTest{ ContentLength: 0, // as if unset by user }, - Body: func() io.ReadCloser { return ioutil.NopCloser(io.LimitReader(strings.NewReader("xx"), 1)) }, + Body: func() io.ReadCloser { return io.NopCloser(io.LimitReader(strings.NewReader("xx"), 1)) }, WantWrite: "POST / HTTP/1.1\r\n" + "Host: example.com\r\n" + @@ -351,7 +350,7 @@ var reqWriteTests = []reqWriteTest{ Body: func() io.ReadCloser { err := errors.New("Custom reader error") errReader := iotest.ErrReader(err) - return ioutil.NopCloser(io.MultiReader(strings.NewReader("x"), errReader)) + return io.NopCloser(io.MultiReader(strings.NewReader("x"), errReader)) }, WantError: errors.New("Custom reader error"), @@ -371,7 +370,7 @@ var reqWriteTests = []reqWriteTest{ Body: func() io.ReadCloser { err := errors.New("Custom reader error") errReader := iotest.ErrReader(err) - return ioutil.NopCloser(errReader) + return io.NopCloser(errReader) }, WantError: errors.New("Custom reader error"), @@ -620,7 +619,7 @@ func TestRequestWrite(t *testing.T) { } switch b := tt.Body.(type) { case []byte: - tt.Req.Body = ioutil.NopCloser(bytes.NewReader(b)) + tt.Req.Body = io.NopCloser(bytes.NewReader(b)) case func() io.ReadCloser: tt.Req.Body = b() } @@ -716,20 +715,20 @@ func TestRequestWriteTransport(t *testing.T) { }, { method: "GET", - body: ioutil.NopCloser(strings.NewReader("")), + body: io.NopCloser(strings.NewReader("")), want: noContentLengthOrTransferEncoding, }, { method: "GET", clen: -1, - body: ioutil.NopCloser(strings.NewReader("")), + body: io.NopCloser(strings.NewReader("")), want: noContentLengthOrTransferEncoding, }, // A GET with a body, with explicit content length: { method: "GET", clen: 7, - body: ioutil.NopCloser(strings.NewReader("foobody")), + body: io.NopCloser(strings.NewReader("foobody")), want: all(matchSubstr("Content-Length: 7"), matchSubstr("foobody")), }, @@ -737,7 +736,7 @@ func TestRequestWriteTransport(t *testing.T) { { method: "GET", clen: -1, - body: ioutil.NopCloser(strings.NewReader("foobody")), + body: io.NopCloser(strings.NewReader("foobody")), want: all(matchSubstr("Transfer-Encoding: chunked"), matchSubstr("\r\n1\r\nf\r\n"), matchSubstr("oobody")), @@ -747,14 +746,14 @@ func TestRequestWriteTransport(t *testing.T) { { method: "POST", clen: -1, - body: ioutil.NopCloser(strings.NewReader("foobody")), + body: io.NopCloser(strings.NewReader("foobody")), want: all(matchSubstr("Transfer-Encoding: chunked"), matchSubstr("foobody")), }, { method: "POST", clen: -1, - body: ioutil.NopCloser(strings.NewReader("")), + body: io.NopCloser(strings.NewReader("")), want: all(matchSubstr("Transfer-Encoding: chunked")), }, // Verify that a blocking Request.Body doesn't block forever. @@ -766,7 +765,7 @@ func TestRequestWriteTransport(t *testing.T) { tt.afterReqRead = func() { pw.Close() } - tt.body = ioutil.NopCloser(pr) + tt.body = io.NopCloser(pr) }, want: matchSubstr("Transfer-Encoding: chunked"), }, @@ -937,7 +936,7 @@ func dumpRequestOut(req *Request, onReadHeaders func()) ([]byte, error) { } // Ensure all the body is read; otherwise // we'll get a partial dump. - io.Copy(ioutil.Discard, req.Body) + io.Copy(io.Discard, req.Body) req.Body.Close() } dr.c <- strings.NewReader("HTTP/1.1 204 No Content\r\nConnection: close\r\n\r\n") |
