fix: handle close errors

This commit is contained in:
2026-05-12 16:05:36 +02:00
parent 31796543c2
commit b03e90fc47
15 changed files with 36 additions and 33 deletions

View File

@@ -106,7 +106,7 @@ func fetchDocument(ctx context.Context, httpClient *http.Client, url string) (*g
if err != nil {
return nil, fmt.Errorf("request failed: %w", err)
}
defer response.Body.Close()
defer func() { _ = response.Body.Close() }()
if response.StatusCode != http.StatusOK {
// limit body read for error context; avoid reading large error pages
@@ -235,7 +235,7 @@ func fetchProxyText(ctx context.Context, httpClient *http.Client, url string) (s
if err != nil {
return "", fmt.Errorf("proxy request failed: %w", err)
}
defer response.Body.Close()
defer func() { _ = response.Body.Close() }()
if response.StatusCode != http.StatusOK {
return "", fmt.Errorf("proxy status %d", response.StatusCode)