Skip to content

Commit ab1c2fe

Browse files
fix: leaking response body upon PromptObject() error
1 parent 38922cc commit ab1c2fe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

api-prompt-object.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ func (c *Client) PromptObject(ctx context.Context, bucketName, objectName, promp
6868
if err != nil {
6969
return nil, err
7070
}
71-
if resp != nil {
72-
if resp.StatusCode != http.StatusOK {
73-
return nil, httpRespToErrorResponse(resp, bucketName, objectName)
74-
}
71+
72+
if resp.StatusCode != http.StatusOK {
73+
defer closeResponse(resp)
74+
return nil, httpRespToErrorResponse(resp, bucketName, objectName)
7575
}
7676

7777
return resp.Body, nil

0 commit comments

Comments
 (0)