Adjust forward auth to avoid connection leak

This commit is contained in:
Weida Hong 2023-09-09 18:36:05 +08:00 committed by GitHub
parent 561c580701
commit 3216c8ab10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -126,6 +126,7 @@ func (fa *forwardAuth) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
rw.WriteHeader(http.StatusInternalServerError)
return
}
defer forwardResponse.Body.Close()
body, readError := io.ReadAll(forwardResponse.Body)
if readError != nil {
@ -136,7 +137,6 @@ func (fa *forwardAuth) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
rw.WriteHeader(http.StatusInternalServerError)
return
}
defer forwardResponse.Body.Close()
// Pass the forward response's body and selected headers if it
// didn't return a response within the range of [200, 300).