Skip to content

Commit de90a0d

Browse files
authored
Merge pull request #39 from ppiaas/master
fix: http response body need defer close
2 parents c488852 + 588c188 commit de90a0d

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

client.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,14 @@ func httpClient(ctx context.Context, addr string, namespace string, outs []inter
144144
if err != nil {
145145
return clientResponse{}, err
146146
}
147+
defer httpResp.Body.Close()
147148

148149
var resp clientResponse
149150

150151
if err := json.NewDecoder(httpResp.Body).Decode(&resp); err != nil {
151152
return clientResponse{}, xerrors.Errorf("unmarshaling response: %w", err)
152153
}
153154

154-
if err := httpResp.Body.Close(); err != nil {
155-
return clientResponse{}, err
156-
}
157-
158155
if resp.ID != *cr.req.ID {
159156
return clientResponse{}, xerrors.New("request and response id didn't match")
160157
}

0 commit comments

Comments
 (0)