Skip to content

Commit

Permalink
Drains tokeninfo response body to enable TCP connection reuse (#1511)
Browse files Browse the repository at this point in the history
See https://golang.org/pkg/net/http/#Client.Do for details

Signed-off-by: Alexander Yastrebov <[email protected]>
  • Loading branch information
AlexanderYastrebov authored Sep 1, 2020
1 parent 9bb4fdb commit fbb171f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions filters/auth/authclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
Expand Down Expand Up @@ -80,6 +81,7 @@ func (ac *authClient) getTokenintrospect(token string, ctx filters.FilterContext
defer rsp.Body.Close()

if rsp.StatusCode != 200 {
io.Copy(ioutil.Discard, rsp.Body)
return nil, errInvalidToken
}

Expand Down Expand Up @@ -110,6 +112,7 @@ func (ac *authClient) getTokeninfo(token string, ctx filters.FilterContext) (map
defer rsp.Body.Close()

if rsp.StatusCode != 200 {
io.Copy(ioutil.Discard, rsp.Body)
return doc, errInvalidToken
}

Expand Down

0 comments on commit fbb171f

Please sign in to comment.