Prevent superfluous response.WriteHeader (#15456)

This PR simply checks the status before writing the header.

Signed-off-by: Andrew Thornton <art27@cantab.net>
tokarchuk/v1.17
zeripath 4 years ago committed by GitHub
parent 55eb1745bd
commit 8e2a8efd84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      modules/context/response.go

@ -4,7 +4,9 @@
package context
import "net/http"
import (
"net/http"
)
// ResponseWriter represents a response writer for HTTP
type ResponseWriter interface {
@ -60,9 +62,11 @@ func (r *Response) WriteHeader(statusCode int) {
}
r.beforeExecuted = true
}
if r.status == 0 {
r.status = statusCode
r.ResponseWriter.WriteHeader(statusCode)
}
}
// Flush flush cached data
func (r *Response) Flush() {

Loading…
Cancel
Save