Skip to content

Commit

Permalink
Close reponse right after succesful request (kyverno#8894) (kyverno#8896
Browse files Browse the repository at this point in the history
)

Signed-off-by: AdamKorcz <[email protected]>
Co-authored-by: AdamKorcz <[email protected]>
  • Loading branch information
gcp-cherry-pick-bot[bot] and AdamKorcz authored Nov 13, 2023
1 parent 208ac97 commit 1fc15cc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/engine/apicall/apiCall.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func (a *apiCall) executeServiceCall(ctx context.Context, apiCall *kyvernov1.API
if err != nil {
return nil, fmt.Errorf("failed to execute HTTP request for APICall %s: %w", a.entry.Name, err)
}
defer resp.Body.Close()

if resp.StatusCode < 200 || resp.StatusCode >= 300 {
b, err := io.ReadAll(resp.Body)
Expand All @@ -137,7 +138,6 @@ func (a *apiCall) executeServiceCall(ctx context.Context, apiCall *kyvernov1.API
return nil, fmt.Errorf("HTTP %s", resp.Status)
}

defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read data from APICall %s: %w", a.entry.Name, err)
Expand Down

0 comments on commit 1fc15cc

Please sign in to comment.