Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion components/tool/duckduckgo/ddgsearch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ func (d *DDGS) sendRequestWithRetry(ctx context.Context, req *http.Request, para

break
}

defer resp.Body.Close()

// Read response body
Expand All @@ -166,6 +165,11 @@ func (d *DDGS) sendRequestWithRetry(ctx context.Context, req *http.Request, para
return nil, fmt.Errorf("failed to read response body: %w", err)
}

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("request duckduckgo failed with status code: %d, msg=%v",
resp.StatusCode, string(body))
}

// Parse search response
response, err := parseSearchResponse(body)
if err != nil {
Expand Down
Loading