Only emit a warning is the status code changes

This commit is contained in:
Manu Mtz-Almeida 2015-05-12 18:31:31 +02:00
parent 99694bb716
commit 59c836e1fa
1 changed files with 3 additions and 3 deletions

View File

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