Skip to content

Commit

Permalink
Merge pull request #28 from viant/http_mem_leak
Browse files Browse the repository at this point in the history
patched http mem leak
  • Loading branch information
adranwit authored Oct 11, 2024
2 parents a6a3adc + 2f46e6e commit 265e18f
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions shared/client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"golang.org/x/net/http2"
)

//Service represent mly client
// Service represent mly client
type Service struct {
Config
hostIndex int64
Expand Down Expand Up @@ -577,25 +577,20 @@ func (s *Service) httpPost(ctx context.Context, data []byte, host *Host) ([]byte
postErr = err
continue
}

var data []byte
if response.StatusCode != http.StatusOK {
return nil, fmt.Errorf("invalid response: %v, %s", response.StatusCode, data)
}

if response.Body != nil {
data, err = io.ReadAll(response.Body)
_ = response.Body.Close()

if err != nil {
postErr = err
continue
}

return data, nil
}
if response.StatusCode != http.StatusOK {
return nil, fmt.Errorf("invalid response: %v, %s", response.StatusCode, data)
}
return data, nil
}

return nil, postErr
}

Expand Down

0 comments on commit 265e18f

Please sign in to comment.