chore: fix deprecated ioutil nopcloser (#27650)

Signed-off-by: idnandre <andre@idntimes.com>
This commit is contained in:
idnandre
2024-07-04 00:38:34 +07:00
committed by GitHub
parent 3229cf192b
commit b833d4714d
10 changed files with 17 additions and 19 deletions

View File

@@ -7,7 +7,6 @@ import (
"bytes"
"encoding/json"
"io"
"io/ioutil"
"net/http"
"net/url"
@@ -77,13 +76,13 @@ func (r *Request) ToHTTP() (*http.Request, error) {
// No body
case r.BodyBytes != nil:
req.Request.Body = ioutil.NopCloser(bytes.NewReader(r.BodyBytes))
req.Request.Body = io.NopCloser(bytes.NewReader(r.BodyBytes))
default:
if c, ok := r.Body.(io.ReadCloser); ok {
req.Request.Body = c
} else {
req.Request.Body = ioutil.NopCloser(r.Body)
req.Request.Body = io.NopCloser(r.Body)
}
}

View File

@@ -8,7 +8,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
)
@@ -44,7 +43,7 @@ func (r *Response) Error() error {
}
r.Body.Close()
r.Body = ioutil.NopCloser(bodyBuf)
r.Body = io.NopCloser(bodyBuf)
ns := r.Header.Get(NamespaceHeaderName)
// Build up the error object