registry: v1Endpoint.ping: don't io.Readall the response
We have the response available, which is an io.Reader, so we don't have to read the entire response into memory before decoding. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
e9ad878df6
commit
0c6f8f9290
1 changed files with 1 additions and 7 deletions
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
@ -150,17 +149,12 @@ func (e *v1Endpoint) ping() (v1PingResult, error) {
|
|||
return info, nil
|
||||
}
|
||||
|
||||
jsonString, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return v1PingResult{}, invalidParamWrapf(err, "error while reading response from %s", pingURL)
|
||||
}
|
||||
|
||||
// If the header is absent, we assume true for compatibility with earlier
|
||||
// versions of the registry. default to true
|
||||
info := v1PingResult{
|
||||
Standalone: true,
|
||||
}
|
||||
if err := json.Unmarshal(jsonString, &info); err != nil {
|
||||
if err := json.NewDecoder(resp.Body).Decode(&info); err != nil {
|
||||
log.G(context.TODO()).WithError(err).Debug("error unmarshaling _ping response")
|
||||
// don't stop here. Just assume sane defaults
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue