Update to go1.16
This commit is contained in:
parent
2e7833df49
commit
bdba7d3adf
62 changed files with 217 additions and 318 deletions
|
@ -2,7 +2,7 @@ package router
|
|||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
|
@ -827,7 +827,7 @@ func BenchmarkRouterServe(b *testing.B) {
|
|||
|
||||
res := &http.Response{
|
||||
StatusCode: 200,
|
||||
Body: ioutil.NopCloser(strings.NewReader("")),
|
||||
Body: io.NopCloser(strings.NewReader("")),
|
||||
}
|
||||
|
||||
routersConfig := map[string]*dynamic.Router{
|
||||
|
@ -879,7 +879,7 @@ func BenchmarkRouterServe(b *testing.B) {
|
|||
func BenchmarkService(b *testing.B) {
|
||||
res := &http.Response{
|
||||
StatusCode: 200,
|
||||
Body: ioutil.NopCloser(strings.NewReader("")),
|
||||
Body: io.NopCloser(strings.NewReader("")),
|
||||
}
|
||||
|
||||
serviceConfig := map[string]*dynamic.Service{
|
||||
|
|
|
@ -48,7 +48,7 @@ func TestShutdownTCP(t *testing.T) {
|
|||
for {
|
||||
_, err := http.ReadRequest(bufio.NewReader(conn))
|
||||
|
||||
if errors.Is(err, io.EOF) || (err != nil && strings.HasSuffix(err.Error(), "use of closed network connection")) {
|
||||
if errors.Is(err, io.EOF) || (err != nil && errors.Is(err, net.ErrClosed)) {
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
@ -88,7 +87,7 @@ func (m *Mirroring) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||
}
|
||||
|
||||
if errors.Is(err, errBodyTooLarge) {
|
||||
req.Body = ioutil.NopCloser(io.MultiReader(bytes.NewReader(bytesRead), req.Body))
|
||||
req.Body = io.NopCloser(io.MultiReader(bytes.NewReader(bytesRead), req.Body))
|
||||
m.handler.ServeHTTP(rw, req)
|
||||
logger.Debugf("no mirroring, request body larger than allowed size")
|
||||
return
|
||||
|
@ -182,7 +181,7 @@ func newReusableRequest(req *http.Request, maxBodySize int64) (*reusableRequest,
|
|||
|
||||
// unbounded body size
|
||||
if maxBodySize < 0 {
|
||||
body, err := ioutil.ReadAll(req.Body)
|
||||
body, err := io.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -217,7 +216,7 @@ func (rr reusableRequest) clone(ctx context.Context) *http.Request {
|
|||
req := rr.req.Clone(ctx)
|
||||
|
||||
if rr.body != nil {
|
||||
req.Body = ioutil.NopCloser(bytes.NewReader(rr.body))
|
||||
req.Body = io.NopCloser(bytes.NewReader(rr.body))
|
||||
}
|
||||
|
||||
return req
|
||||
|
|
|
@ -3,7 +3,7 @@ package mirror
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"sync/atomic"
|
||||
|
@ -148,7 +148,7 @@ func TestMirroringWithBody(t *testing.T) {
|
|||
|
||||
handler := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
assert.NotNil(t, r.Body)
|
||||
bb, err := ioutil.ReadAll(r.Body)
|
||||
bb, err := io.ReadAll(r.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, body, bb)
|
||||
rw.WriteHeader(http.StatusOK)
|
||||
|
@ -159,7 +159,7 @@ func TestMirroringWithBody(t *testing.T) {
|
|||
for i := 0; i < numMirrors; i++ {
|
||||
err := mirror.AddMirror(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
assert.NotNil(t, r.Body)
|
||||
bb, err := ioutil.ReadAll(r.Body)
|
||||
bb, err := io.ReadAll(r.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, body, bb)
|
||||
atomic.AddInt32(&countMirror, 1)
|
||||
|
@ -213,13 +213,13 @@ func TestCloneRequest(t *testing.T) {
|
|||
|
||||
// first call
|
||||
cloned := rr.clone(ctx)
|
||||
body, err := ioutil.ReadAll(cloned.Body)
|
||||
body, err := io.ReadAll(cloned.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, bb, body)
|
||||
|
||||
// second call
|
||||
cloned = rr.clone(ctx)
|
||||
body, err = ioutil.ReadAll(cloned.Body)
|
||||
body, err = io.ReadAll(cloned.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, bb, body)
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
|
@ -21,7 +21,7 @@ func (t *staticTransport) RoundTrip(r *http.Request) (*http.Response, error) {
|
|||
func BenchmarkProxy(b *testing.B) {
|
||||
res := &http.Response{
|
||||
StatusCode: 200,
|
||||
Body: ioutil.NopCloser(strings.NewReader("")),
|
||||
Body: io.NopCloser(strings.NewReader("")),
|
||||
}
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue