Skip to content

Commit

Permalink
fix(candidatefinder): fix streaming ndjson response
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahhoward committed Mar 3, 2023
1 parent 0a8b8fa commit de30877
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/indexerlookup/candidatefinder.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ func (idxf *IndexerCandidateFinder) FindCandidatesAsync(ctx context.Context, c c
}
switch resp.StatusCode {
case http.StatusOK:
defer resp.Body.Close()
return idxf.decodeProviderResultStream(ctx, c, resp.Body)
case http.StatusNotFound:
return nil, nil
Expand All @@ -153,10 +152,11 @@ func (idxf *IndexerCandidateFinder) newFindHttpRequest(ctx context.Context, c ci
return req, nil
}

func (idxf *IndexerCandidateFinder) decodeProviderResultStream(ctx context.Context, c cid.Cid, from io.Reader) (<-chan types.FindCandidatesResult, error) {
func (idxf *IndexerCandidateFinder) decodeProviderResultStream(ctx context.Context, c cid.Cid, from io.ReadCloser) (<-chan types.FindCandidatesResult, error) {
rch := make(chan types.FindCandidatesResult, idxf.asyncResultsChanBuffer)
go func() {
defer close(rch)
defer from.Close()
scanner := bufio.NewScanner(from)
for {
var r types.FindCandidatesResult
Expand Down

0 comments on commit de30877

Please sign in to comment.