From 20301bc2125b9aebb22a849cc76b4bb3ecb3f404 Mon Sep 17 00:00:00 2001 From: JessonChan Date: Wed, 24 Feb 2016 10:31:44 +0800 Subject: [PATCH] multiple response.WriteHeader calls --- context/context.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/context/context.go b/context/context.go index db790ff2..837a1b45 100644 --- a/context/context.go +++ b/context/context.go @@ -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)