Skip to content

Commit

Permalink
chore(database): Ensure response body is always drained
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Aug 13, 2024
1 parent f80d683 commit 762e2fd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/database/generate/download/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ func (g *Downloader) prepareDownload(ctx context.Context, postFields map[string]
if err != nil {
return "", "", "", err
}
defer func() {
_, _ = io.Copy(io.Discard, res.Body)
_ = res.Body.Close()
}()

doc, err := goquery.NewDocumentFromReader(res.Body)
if err != nil {
Expand All @@ -298,10 +302,6 @@ func (g *Downloader) prepareDownload(ctx context.Context, postFields map[string]
return "", "", "", ErrNoButton
}

// Drain response body
_, _ = io.Copy(io.Discard, res.Body)
_ = res.Body.Close()

return url.String(), name, value, nil
}

Expand Down

0 comments on commit 762e2fd

Please sign in to comment.