1
0
Fork 0

Merge current v2.5 into master

This commit is contained in:
romain 2021-09-03 09:13:34 +02:00
commit 4235cef1b2
36 changed files with 117 additions and 82 deletions

View file

@ -1,3 +1,4 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
/*

View file

@ -1,3 +1,4 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
/*

View file

@ -204,7 +204,7 @@ func newReusableRequest(req *http.Request, maxBodySize int64) (*reusableRequest,
if req == nil {
return nil, nil, errors.New("nil input request")
}
if req.Body == nil {
if req.Body == nil || req.ContentLength == 0 {
return &reusableRequest{req: req}, nil, nil
}

View file

@ -243,9 +243,22 @@ func TestCloneRequest(t *testing.T) {
req, err := http.NewRequest(http.MethodPost, "/", buf)
assert.NoError(t, err)
_, expectedBytes, err := newReusableRequest(req, 20)
rr, expectedBytes, err := newReusableRequest(req, 20)
assert.NoError(t, err)
assert.Nil(t, expectedBytes)
assert.Len(t, rr.body, 10)
})
t.Run("valid GET case with maxBodySize", func(t *testing.T) {
buf := bytes.NewBuffer([]byte{})
req, err := http.NewRequest(http.MethodGet, "/", buf)
assert.NoError(t, err)
rr, expectedBytes, err := newReusableRequest(req, 20)
assert.NoError(t, err)
assert.Nil(t, expectedBytes)
assert.Len(t, rr.body, 0)
})
t.Run("no request given", func(t *testing.T) {

View file

@ -1,3 +1,4 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
/*

View file

@ -1,3 +1,4 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
/*