mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #112934 from wzshiming/fix/close-body
Close body when Report non-OK status code
This commit is contained in:
commit
8d6bbfbad2
@ -662,11 +662,11 @@ func getClaimJWT(client *http.Client, url, accessToken string) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
// Report non-OK status code as an error.
|
// Report non-OK status code as an error.
|
||||||
if response.StatusCode < http.StatusOK || response.StatusCode > http.StatusIMUsed {
|
if response.StatusCode < http.StatusOK || response.StatusCode > http.StatusIMUsed {
|
||||||
return "", fmt.Errorf("error while getting distributed claim JWT: %v", response.Status)
|
return "", fmt.Errorf("error while getting distributed claim JWT: %v", response.Status)
|
||||||
}
|
}
|
||||||
defer response.Body.Close()
|
|
||||||
responseBytes, err := ioutil.ReadAll(response.Body)
|
responseBytes, err := ioutil.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("could not decode distributed claim response")
|
return "", fmt.Errorf("could not decode distributed claim response")
|
||||||
|
Loading…
Reference in New Issue
Block a user