diff options
author | zeripath <art27@cantab.net> | 2021-04-14 13:57:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-14 14:57:18 +0200 |
commit | 8e2a8efd84bf39c4dd38f7f4acdc2d7f499f610a (patch) | |
tree | da6dc18b28bc1de4fb72822c2df6a136932b5522 /modules/context | |
parent | 55eb1745bd5427c6f84f77703a580d580ac379b3 (diff) | |
download | gitea-8e2a8efd84bf39c4dd38f7f4acdc2d7f499f610a.tar.gz gitea-8e2a8efd84bf39c4dd38f7f4acdc2d7f499f610a.zip |
Prevent superfluous response.WriteHeader (#15456)
This PR simply checks the status before writing the header.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/context')
-rw-r--r-- | modules/context/response.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/context/response.go b/modules/context/response.go index bdbbb97af7..4ffbd230a2 100644 --- a/modules/context/response.go +++ b/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,8 +62,10 @@ func (r *Response) WriteHeader(statusCode int) { } r.beforeExecuted = true } - r.status = statusCode - r.ResponseWriter.WriteHeader(statusCode) + if r.status == 0 { + r.status = statusCode + r.ResponseWriter.WriteHeader(statusCode) + } } // Flush flush cached data |