Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.

Commit

Permalink
Fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
jerson committed Sep 20, 2021
1 parent 183b9c1 commit 6b39139
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions proto/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ func NewHttp() *Http {
}
}

func extractBody(r io.Reader) ([]byte, io.ReadCloser, error) {
func extractBody(r io.ReadCloser) ([]byte, io.ReadCloser, error) {
buf := new(bytes.Buffer)
_, err := buf.ReadFrom(r)
return buf.Bytes(), ioutil.NopCloser(buf), err
// copied from https://github.com/xinxin8816/ngrok/commit/3463565536ab417d7c0a1d4b6cf5a073c128f944
//_, err := buf.ReadFrom(r)
defer r.Close()
//return buf.Bytes(), ioutil.NopCloser(buf), err
return buf.Bytes(), nil, nil
}

func (h *Http) GetName() string { return "http" }
Expand Down

0 comments on commit 6b39139

Please sign in to comment.