Skip to content

Commit

Permalink
Merge pull request #10 from topfreegames/fix/memory-leak-http-auth
Browse files Browse the repository at this point in the history
Fix memory leak when using http auth
  • Loading branch information
lmsilva-wls committed May 31, 2021
2 parents 6390984 + 94e97ac commit 0a68760
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"bytes"
"context"
"encoding/json"
"io"
"io/ioutil"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -126,6 +128,12 @@ func httpAuthorize(app *App, userID string, topics []string) (bool, []string, er
}

response, err := client.Do(request)
// discard response body
if response != nil && response.Body != nil {
_, _ = io.Copy(ioutil.Discard, response.Body)
_ = response.Body.Close()
}

if err != nil {
return false, nil, err
}
Expand Down

0 comments on commit 0a68760

Please sign in to comment.