mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 12:15:43 +01:00
Prevent superfluous response.WriteHeader (#15456)
This PR simply checks the status before writing the header. Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
55eb1745bd
commit
8e2a8efd84
1 changed files with 7 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue