fix: address code review findings

This commit is contained in:
2026-08-19 12:48:30 +03:00
parent b14682f424
commit 4a7be531ed
4 changed files with 33 additions and 27 deletions

View File

@@ -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)
}