multiple response.WriteHeader calls

This commit is contained in:
JessonChan 2016-02-24 10:31:44 +08:00
parent 2b23764ee0
commit 20301bc212
1 changed files with 4 additions and 0 deletions

View File

@ -187,6 +187,10 @@ func (w *Response) Write(p []byte) (int, error) {
// WriteHeader sends an HTTP response header with status code,
// and sets `started` to true.
func (w *Response) WriteHeader(code int) {
if w.Status > 0 {
//prevent multiple response.WriteHeader calls
return
}
w.Status = code
w.Started = true
w.ResponseWriter.WriteHeader(code)