when the status code changes and Written, ResponseWriter status code should be changed together.Otherwise,logs status code is not same as response.

This commit is contained in:
jarhmj 2021-04-22 23:30:48 +08:00
parent c0418c48e4
commit 5f80e0a7dc

View File

@ -59,10 +59,11 @@ func (w *responseWriter) reset(writer http.ResponseWriter) {
func (w *responseWriter) WriteHeader(code int) {
if code > 0 && w.status != code {
w.status = code
if w.Written() {
debugPrint("[WARNING] Headers were already written. Wanted to override status code %d with %d", w.status, code)
w.ResponseWriter.WriteHeader(code)
}
w.status = code
}
}