fix: address code review findings
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -197,10 +196,9 @@ func (c *Client) executeRequest(ctx context.Context, url string) (*Response, err
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("request failed: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
io.ReadAll(resp.Body) // Drain body to allow connection reuse
|
||||
resp.Body.Close()
|
||||
return nil, newAPIError(resp.StatusCode, resp.Status)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user