Deprecate Go 1.15 (#1379)

* Dropping support for 1.15.

* Replaces Go 1.16 Deprecated functions

* Update test build flag

* Fix import sort and comment

* Update github.com/klauspost/compress to v1.15.9

https://github.com/klauspost/compress improved performance and changed Minimum version is 1.16, this should be the final supported release for Go 1.16 (https://github.com/klauspost/compress/commit/6d0019a95afa3221f7522d1f2eed0033b5e79470) .
This commit is contained in:
Aoang
2022-09-16 03:28:25 +08:00
committed by GitHub
parent 2f1e949d91
commit a696949f6c
24 changed files with 73 additions and 94 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x, 1.19.x]
go-version: [1.16.x, 1.17.x, 1.18.x, 1.19.x]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
-1
View File
@@ -5,7 +5,6 @@ package fasthttp
import (
"net"
"testing"
)
+2 -2
View File
@@ -4,7 +4,7 @@ import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"io"
"testing"
)
@@ -91,7 +91,7 @@ func testBrotliCompressSingleCase(s string) error {
if err != nil {
return fmt.Errorf("unexpected error: %w. s=%q", err, s)
}
body, err := ioutil.ReadAll(zr)
body, err := io.ReadAll(zr)
if err != nil {
return fmt.Errorf("unexpected error: %w. s=%q", err, s)
}
+1 -2
View File
@@ -6,7 +6,6 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
)
@@ -107,7 +106,7 @@ func main() {
fmt.Fprintf(w, "const quotedArgShouldEscapeTable = %q\n", quotedArgShouldEscapeTable)
fmt.Fprintf(w, "const quotedPathShouldEscapeTable = %q\n", quotedPathShouldEscapeTable)
if err := ioutil.WriteFile("bytesconv_table.go", w.Bytes(), 0660); err != nil {
if err := os.WriteFile("bytesconv_table.go", w.Bytes(), 0660); err != nil {
log.Fatal(err)
}
}
+5 -5
View File
@@ -3,7 +3,7 @@ package fasthttp
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"runtime"
@@ -169,7 +169,7 @@ func BenchmarkNetHTTPClientDoFastServer(b *testing.B) {
if resp.StatusCode != http.StatusOK {
b.Fatalf("unexpected status code: %d", resp.StatusCode)
}
respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
b.Fatalf("unexpected error when reading response body: %v", err)
@@ -297,7 +297,7 @@ func benchmarkNetHTTPClientGetEndToEndTCP(b *testing.B, parallelism int) {
if resp.StatusCode != http.StatusOK {
b.Fatalf("unexpected status code: %d. Expecting %d", resp.StatusCode, http.StatusOK)
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
b.Fatalf("unexpected error when reading response body: %v", err)
@@ -427,7 +427,7 @@ func benchmarkNetHTTPClientGetEndToEndInmemory(b *testing.B, parallelism int) {
if resp.StatusCode != http.StatusOK {
b.Fatalf("unexpected status code: %d. Expecting %d", resp.StatusCode, http.StatusOK)
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
b.Fatalf("unexpected error when reading response body: %v", err)
@@ -554,7 +554,7 @@ func benchmarkNetHTTPClientEndToEndBigResponseInmemory(b *testing.B, parallelism
if resp.StatusCode != http.StatusOK {
b.Fatalf("unexpected status code: %d. Expecting %d", resp.StatusCode, http.StatusOK)
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
b.Fatalf("unexpected error when reading response body: %v", err)
+2 -5
View File
@@ -1,10 +1,7 @@
//go:build go1.11
// +build go1.11
package fasthttp
import (
"io/ioutil"
"io"
"net"
"net/http"
"strings"
@@ -146,7 +143,7 @@ func benchmarkNetHTTPClientGetEndToEndWaitConnInmemory(b *testing.B, parallelism
if resp.StatusCode != http.StatusOK {
b.Fatalf("unexpected status code: %d. Expecting %d", resp.StatusCode, http.StatusOK)
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
b.Fatalf("unexpected error when reading response body: %v", err)
+2 -3
View File
@@ -5,7 +5,6 @@ package fasthttp
import (
"io"
"io/ioutil"
"net"
"net/http"
"strings"
@@ -32,7 +31,7 @@ func TestRstConnResponseWhileSending(t *testing.T) {
// Read at least one byte of the header
// Otherwise we would have an unsolicited response
_, err = ioutil.ReadAll(io.LimitReader(conn, 1))
_, err = io.ReadAll(io.LimitReader(conn, 1))
if err != nil {
t.Error(err)
}
@@ -94,7 +93,7 @@ func TestRstConnClosedWithoutResponse(t *testing.T) {
// Read at least one byte of the header
// Otherwise we would have an unsolicited response
_, err = ioutil.ReadAll(io.LimitReader(conn, 1))
_, err = io.ReadAll(io.LimitReader(conn, 1))
if err != nil {
t.Error(err)
}
+3 -3
View File
@@ -3,7 +3,7 @@ package fasthttp
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"testing"
"time"
)
@@ -173,7 +173,7 @@ func testGzipCompressSingleCase(s string) error {
if err != nil {
return fmt.Errorf("unexpected error: %w. s=%q", err, s)
}
body, err := ioutil.ReadAll(zr)
body, err := io.ReadAll(zr)
if err != nil {
return fmt.Errorf("unexpected error: %w. s=%q", err, s)
}
@@ -196,7 +196,7 @@ func testFlateCompressSingleCase(s string) error {
if err != nil {
return fmt.Errorf("unexpected error: %w. s=%q", err, s)
}
body, err := ioutil.ReadAll(zr)
body, err := io.ReadAll(zr)
if err != nil {
return fmt.Errorf("unexpected error: %w. s=%q", err, s)
}
+2 -2
View File
@@ -2,7 +2,7 @@ package fasthttpadaptor
import (
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"net/url"
@@ -66,7 +66,7 @@ func TestNewFastHTTPHandler(t *testing.T) {
if r.RemoteAddr != expectedRemoteAddr {
t.Fatalf("unexpected remoteAddr %q. Expecting %q", r.RemoteAddr, expectedRemoteAddr)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
r.Body.Close()
if err != nil {
t.Fatalf("unexpected error when reading request body: %v", err)
+2 -2
View File
@@ -2,7 +2,7 @@ package fasthttpadaptor
import (
"bytes"
"io/ioutil"
"io"
"net/http"
"net/url"
@@ -28,7 +28,7 @@ func ConvertRequest(ctx *fasthttp.RequestCtx, r *http.Request, forServer bool) e
r.RemoteAddr = ctx.RemoteAddr().String()
r.Host = string(ctx.Host())
r.TLS = ctx.TLSConnectionState()
r.Body = ioutil.NopCloser(bytes.NewReader(body))
r.Body = io.NopCloser(bytes.NewReader(body))
r.URL = rURL
if forServer {
+2 -3
View File
@@ -9,9 +9,8 @@ import (
"sync/atomic"
"time"
"golang.org/x/net/http/httpproxy"
"github.com/valyala/fasthttp"
"golang.org/x/net/http/httpproxy"
)
const (
@@ -32,7 +31,7 @@ func FasthttpProxyHTTPDialer() fasthttp.DialFunc {
return FasthttpProxyHTTPDialerTimeout(0)
}
// FasthttpProxyHTTPDialer returns a fasthttp.DialFunc that dials using
// FasthttpProxyHTTPDialerTimeout returns a fasthttp.DialFunc that dials using
// the env(HTTP_PROXY, HTTPS_PROXY and NO_PROXY) configured HTTP proxy using the given timeout.
//
// Example usage:
+1 -2
View File
@@ -5,7 +5,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"sync"
@@ -147,7 +146,7 @@ func testInmemoryListenerHTTPSingle(t *testing.T, client *http.Client, content s
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
b, err := ioutil.ReadAll(res.Body)
b, err := io.ReadAll(res.Body)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
+1 -2
View File
@@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net"
"testing"
"time"
@@ -162,7 +161,7 @@ func testPipeConnsCloseWhileReadWrite(t *testing.T) {
readCh := make(chan error)
go func() {
var err error
if _, err = io.Copy(ioutil.Discard, c1); err != nil {
if _, err = io.Copy(io.Discard, c1); err != nil {
if err != errConnectionClosed {
err = fmt.Errorf("unexpected error: %w", err)
} else {
+1 -2
View File
@@ -6,7 +6,6 @@ import (
"fmt"
"html"
"io"
"io/ioutil"
"mime"
"net/http"
"os"
@@ -1377,7 +1376,7 @@ func readFileHeader(f *os.File, compressed bool, fileEncoding string) ([]byte, e
R: r,
N: 512,
}
data, err := ioutil.ReadAll(lr)
data, err := io.ReadAll(lr)
if _, err := f.Seek(0, 0); err != nil {
return nil, err
}
+6 -10
View File
@@ -1,6 +1,3 @@
// go:build !windows
// Don't run FS tests on windows as it isn't compatible for now.
package fasthttp
import (
@@ -8,7 +5,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"path"
@@ -158,13 +154,13 @@ func TestServeFileSmallNoReadFrom(t *testing.T) {
teststr := "hello, world!"
tempdir, err := ioutil.TempDir("", "httpexpect")
tempdir, err := os.MkdirTemp("", "httpexpect")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tempdir)
if err := ioutil.WriteFile(
if err := os.WriteFile(
path.Join(tempdir, "hello"), []byte(teststr), 0666); err != nil {
t.Fatal(err)
}
@@ -412,7 +408,7 @@ func getFileContents(path string) ([]byte, error) {
return nil, err
}
defer f.Close()
return ioutil.ReadAll(f)
return io.ReadAll(f)
}
func TestParseByteRangeSuccess(t *testing.T) {
@@ -703,7 +699,7 @@ func fsHandlerTest(t *testing.T, requestHandler RequestHandler, filenames []stri
f.Close()
continue
}
data, err := ioutil.ReadAll(f)
data, err := io.ReadAll(f)
f.Close()
if err != nil {
t.Fatalf("cannot read file contents %q: %v", name, err)
@@ -714,7 +710,7 @@ func fsHandlerTest(t *testing.T, requestHandler RequestHandler, filenames []stri
if ctx.Response.bodyStream == nil {
t.Fatalf("response body stream must be non-empty")
}
body, err := ioutil.ReadAll(ctx.Response.bodyStream)
body, err := io.ReadAll(ctx.Response.bodyStream)
if err != nil {
t.Fatalf("error when reading response body stream: %v", err)
}
@@ -733,7 +729,7 @@ func fsHandlerTest(t *testing.T, requestHandler RequestHandler, filenames []stri
if ctx.Response.bodyStream == nil {
t.Fatalf("response body stream must be non-empty")
}
body, err := ioutil.ReadAll(ctx.Response.bodyStream)
body, err := io.ReadAll(ctx.Response.bodyStream)
if err != nil {
t.Fatalf("error when reading response body stream: %v", err)
}
+2 -2
View File
@@ -1,10 +1,10 @@
module github.com/valyala/fasthttp
go 1.15
go 1.16
require (
github.com/andybalholm/brotli v1.0.4
github.com/klauspost/compress v1.15.0
github.com/klauspost/compress v1.15.9
github.com/valyala/bytebufferpool v1.0.0
github.com/valyala/tcplisten v1.0.0
golang.org/x/crypto v0.0.0-20220214200702-86341886e292
+2 -2
View File
@@ -1,7 +1,7 @@
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/klauspost/compress v1.15.0 h1:xqfchp4whNFxn5A4XFyyYtitiWI8Hy5EW59jEwcyL6U=
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
+3 -4
View File
@@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"math"
"mime/multipart"
"net/http"
@@ -655,7 +654,7 @@ tailfoobar`
t.Fatalf("unexpected error: %v", err)
}
tail, err := ioutil.ReadAll(br)
tail, err := io.ReadAll(br)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@@ -1241,7 +1240,7 @@ func TestRequestReadPostNoBody(t *testing.T) {
t.Fatalf("unexpected content-length: %d. Expecting 0", r.Header.ContentLength())
}
tail, err := ioutil.ReadAll(br)
tail, err := io.ReadAll(br)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@@ -1272,7 +1271,7 @@ func TestRequestContinueReadBody(t *testing.T) {
t.Fatalf("unexpected body %q. Expecting %q", body, "abcde")
}
tail, err := ioutil.ReadAll(br)
tail, err := io.ReadAll(br)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
+24 -27
View File
@@ -1,5 +1,3 @@
// go:build !windows || !race
package fasthttp
import (
@@ -10,7 +8,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net"
"os"
@@ -351,7 +348,7 @@ func TestSaveMultipartFile(t *testing.T) {
}
defer os.Remove("filea.txt")
if c, err := ioutil.ReadFile("filea.txt"); err != nil {
if c, err := os.ReadFile("filea.txt"); err != nil {
t.Fatal(err)
} else if string(c) != filea {
t.Fatalf("filea changed expected %q got %q", filea, c)
@@ -371,7 +368,7 @@ func TestSaveMultipartFile(t *testing.T) {
}
defer os.Remove("fileb.txt")
if c, err := ioutil.ReadFile("fileb.txt"); err != nil {
if c, err := os.ReadFile("fileb.txt"); err != nil {
t.Fatal(err)
} else if string(c) != fileb {
t.Fatalf("fileb changed expected %q got %q", fileb, c)
@@ -394,7 +391,7 @@ func TestServerName(t *testing.T) {
t.Fatalf("Unexpected error from serveConn: %v", err)
}
resp, err := ioutil.ReadAll(&rw.w)
resp, err := io.ReadAll(&rw.w)
if err != nil {
t.Fatalf("Unexpected error from ReadAll: %v", err)
}
@@ -738,7 +735,7 @@ func TestServerResponseBodyStream(t *testing.T) {
}
close(readyCh)
tail, err := ioutil.ReadAll(br)
tail, err := io.ReadAll(br)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
@@ -811,7 +808,7 @@ func TestServerDisableKeepalive(t *testing.T) {
}
// make sure the connection is closed
data, err := ioutil.ReadAll(br)
data, err := io.ReadAll(br)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
@@ -1584,7 +1581,7 @@ func TestServerHTTP10ConnectionKeepAlive(t *testing.T) {
tailCh := make(chan struct{})
go func() {
tail, err := ioutil.ReadAll(br)
tail, err := io.ReadAll(br)
if err != nil {
t.Errorf("error when reading tail: %v", err)
}
@@ -1659,7 +1656,7 @@ func TestServerHTTP10ConnectionClose(t *testing.T) {
tailCh := make(chan struct{})
go func() {
tail, err := ioutil.ReadAll(br)
tail, err := io.ReadAll(br)
if err != nil {
t.Errorf("error when reading tail: %v", err)
}
@@ -1795,7 +1792,7 @@ func TestServerHeadRequest(t *testing.T) {
t.Fatalf("unexpected content-type %q. Expecting %q", resp.Header.ContentType(), "aaa/bbb")
}
data, err := ioutil.ReadAll(br)
data, err := io.ReadAll(br)
if err != nil {
t.Fatalf("Unexpected error when reading remaining data: %v", err)
}
@@ -1836,7 +1833,7 @@ func TestServerExpect100Continue(t *testing.T) {
br := bufio.NewReader(&rw.w)
verifyResponse(t, br, StatusOK, string(defaultContentType), "foobar")
data, err := ioutil.ReadAll(br)
data, err := io.ReadAll(br)
if err != nil {
t.Fatalf("Unexpected error when reading remaining data: %v", err)
}
@@ -1892,7 +1889,7 @@ func TestServerContinueHandler(t *testing.T) {
br := bufio.NewReader(&rw.w)
verifyResponse(t, br, expectedStatusCode, string(defaultContentType), expectedResponse)
data, err := ioutil.ReadAll(br)
data, err := io.ReadAll(br)
if err != nil {
t.Fatalf("Unexpected error when reading remaining data: %v", err)
}
@@ -2235,7 +2232,7 @@ func TestServeConnNonHTTP11KeepAlive(t *testing.T) {
t.Fatal("expecting Connection: close")
}
data, err := ioutil.ReadAll(br)
data, err := io.ReadAll(br)
if err != nil {
t.Fatalf("Unexpected error when reading remaining data: %v", err)
}
@@ -2377,7 +2374,7 @@ func TestRequestCtxSendFileModified(t *testing.T) {
if err != nil {
t.Fatalf("cannot open file: %v", err)
}
body, err := ioutil.ReadAll(f)
body, err := io.ReadAll(f)
f.Close()
if err != nil {
t.Fatalf("error when reading file: %v", err)
@@ -2420,7 +2417,7 @@ func TestRequestCtxSendFile(t *testing.T) {
if err != nil {
t.Fatalf("cannot open file: %v", err)
}
body, err := ioutil.ReadAll(f)
body, err := io.ReadAll(f)
f.Close()
if err != nil {
t.Fatalf("error when reading file: %v", err)
@@ -2521,7 +2518,7 @@ func testRequestCtxHijack(t *testing.T, s *Server) {
br := bufio.NewReader(&rw.w)
verifyResponse(t, br, StatusOK, "foo/bar", "hijack it!")
data, err := ioutil.ReadAll(br)
data, err := io.ReadAll(br)
if err != nil {
t.Errorf("[iter: %d] Unexpected error when reading remaining data: %v", id, err)
@@ -2884,7 +2881,7 @@ func TestServerTimeoutErrorWithResponse(t *testing.T) {
verifyResponse(t, br, 456, "foo/bar", "path=/foo")
verifyResponse(t, br, 456, "foo/bar", "path=/bar")
data, err := ioutil.ReadAll(br)
data, err := io.ReadAll(br)
if err != nil {
t.Fatalf("Unexpected error when reading remaining data: %v", err)
}
@@ -2918,7 +2915,7 @@ func TestServerTimeoutErrorWithCode(t *testing.T) {
verifyResponse(t, br, StatusBadRequest, string(defaultContentType), "stolen ctx")
verifyResponse(t, br, StatusBadRequest, string(defaultContentType), "stolen ctx")
data, err := ioutil.ReadAll(br)
data, err := io.ReadAll(br)
if err != nil {
t.Fatalf("Unexpected error when reading remaining data: %v", err)
}
@@ -2952,7 +2949,7 @@ func TestServerTimeoutError(t *testing.T) {
verifyResponse(t, br, StatusRequestTimeout, string(defaultContentType), "stolen ctx")
verifyResponse(t, br, StatusRequestTimeout, string(defaultContentType), "stolen ctx")
data, err := ioutil.ReadAll(br)
data, err := io.ReadAll(br)
if err != nil {
t.Fatalf("Unexpected error when reading remaining data: %v", err)
}
@@ -2987,7 +2984,7 @@ func TestServerMaxRequestsPerConn(t *testing.T) {
}
verifyResponseHeader(t, &resp.Header, 200, 0, string(defaultContentType), "")
data, err := ioutil.ReadAll(br)
data, err := io.ReadAll(br)
if err != nil {
t.Fatalf("Unexpected error when reading remaining data: %v", err)
}
@@ -3023,7 +3020,7 @@ func TestServerConnectionClose(t *testing.T) {
t.Fatal("expecting Connection: close header")
}
data, err := ioutil.ReadAll(br)
data, err := io.ReadAll(br)
if err != nil {
t.Fatalf("Unexpected error when reading remaining data: %v", err)
}
@@ -3686,7 +3683,7 @@ func TestStreamRequestBody(t *testing.T) {
pipe := fasthttputil.NewPipeConns()
cc, sc := pipe.Conn1(), pipe.Conn2()
//write headers and part1 body
// write headers and part1 body
if _, err := cc.Write([]byte(fmt.Sprintf("POST /foo2 HTTP/1.1\r\nHost: aaa.com\r\nContent-Length: %d\r\nContent-Type: aa\r\n\r\n", contentLength))); err != nil {
t.Fatal(err)
}
@@ -3743,7 +3740,7 @@ func TestStreamRequestBodyExceedMaxSize(t *testing.T) {
pipe := fasthttputil.NewPipeConns()
cc, sc := pipe.Conn1(), pipe.Conn2()
//write headers and part1 body
// write headers and part1 body
if _, err := cc.Write([]byte(fmt.Sprintf("POST /foo2 HTTP/1.1\r\nHost: aaa.com\r\nContent-Length: %d\r\nContent-Type: aa\r\n\r\n%s", contentLength, part1))); err != nil {
t.Error(err)
}
@@ -3845,12 +3842,12 @@ func TestMaxReadTimeoutPerRequest(t *testing.T) {
pipe := fasthttputil.NewPipeConns()
cc, sc := pipe.Conn1(), pipe.Conn2()
go func() {
//write headers
// write headers
_, err := cc.Write(headers)
if err != nil {
t.Error(err)
}
//write body
// write body
for i := 0; i < 5*1024; i++ {
time.Sleep(time.Millisecond)
cc.Write([]byte{'a'}) //nolint:errcheck
@@ -3899,7 +3896,7 @@ func TestMaxWriteTimeoutPerRequest(t *testing.T) {
var resp Response
go func() {
//write headers
// write headers
_, err := cc.Write(headers)
if err != nil {
t.Error(err)
+1 -2
View File
@@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"runtime"
@@ -393,7 +392,7 @@ func benchmarkNetHTTPServerPost(b *testing.B, clientsCount, requestsPerConn int)
if req.Method != MethodPost {
b.Fatalf("Unexpected request method: %q", req.Method)
}
body, err := ioutil.ReadAll(req.Body)
body, err := io.ReadAll(req.Body)
if err != nil {
b.Fatalf("Unexpected error: %v", err)
}
+1 -2
View File
@@ -6,7 +6,6 @@ import (
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"testing"
"time"
)
@@ -96,7 +95,7 @@ func testWriterReuse(w Writer, r io.Reader, newReader func(io.Reader) io.Reader)
w.Close()
zr := newReader(r)
data, err := ioutil.ReadAll(zr)
data, err := io.ReadAll(zr)
if err != nil {
return fmt.Errorf("unexpected error: %w, data=%q", err, data)
}
+2 -3
View File
@@ -4,7 +4,6 @@ import (
"bufio"
"fmt"
"io"
"io/ioutil"
"testing"
"time"
)
@@ -19,7 +18,7 @@ func TestNewStreamReader(t *testing.T) {
close(ch)
})
data, err := ioutil.ReadAll(r)
data, err := io.ReadAll(r)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@@ -88,7 +87,7 @@ func TestStreamReaderClose(t *testing.T) {
// read trailing data
go func() {
if _, err := ioutil.ReadAll(r); err != nil {
if _, err := io.ReadAll(r); err != nil {
ch <- fmt.Errorf("unexpected error when reading trailing data: %w", err)
return
}
+5 -5
View File
@@ -4,7 +4,7 @@ import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"io"
"sync"
"testing"
"time"
@@ -36,7 +36,7 @@ aaaaaaaaaa`
if string(ctx.Path()) == "/one" {
body = string(ctx.PostBody())
} else {
all, err := ioutil.ReadAll(ctx.RequestBodyStream())
all, err := io.ReadAll(ctx.RequestBodyStream())
if err != nil {
t.Error(err)
}
@@ -106,9 +106,9 @@ func getChunkedTestEnv(t testing.TB) (*fasthttputil.InmemoryListener, []byte) {
chunkedBody := createChunkedBody(body, nil, true)
testHandler := func(ctx *RequestCtx) {
bodyBytes, err := ioutil.ReadAll(ctx.RequestBodyStream())
bodyBytes, err := io.ReadAll(ctx.RequestBodyStream())
if err != nil {
t.Logf("ioutil read returned err=%v", err)
t.Logf("io read returned err=%v", err)
t.Error("unexpected error while reading request body stream")
}
@@ -164,7 +164,7 @@ Trailer: Foo, Bar
s := &Server{
StreamRequestBody: true,
Handler: func(ctx *RequestCtx) {
all, err := ioutil.ReadAll(ctx.RequestBodyStream())
all, err := io.ReadAll(ctx.RequestBodyStream())
if err != nil {
t.Errorf("unexpected error: %v", err)
}
+2 -2
View File
@@ -1,7 +1,7 @@
package fasthttp
import (
"io/ioutil"
"io"
"net"
"testing"
"time"
@@ -118,7 +118,7 @@ func testWorkerPoolMaxWorkersCount(t *testing.T) {
if _, err = conn.Write([]byte("foobar")); err != nil {
t.Errorf("unexpected error: %v", err)
}
data, err := ioutil.ReadAll(conn)
data, err := io.ReadAll(conn)
if err != nil {
t.Errorf("unexpected error: %v", err)
}