From 6aaca2eca8f04e14a78c0ca324ce6a8d066f3d02 Mon Sep 17 00:00:00 2001 From: nkbai Date: Thu, 26 Nov 2015 14:56:39 +0800 Subject: [PATCH] =?UTF-8?q?router.go=20Header=20=E6=AF=AB=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E5=A4=84=20context/output.go=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E4=B8=80=E4=B8=8B=E4=BB=A3=E7=A0=81,=E6=9B=B4=E6=B8=85?= =?UTF-8?q?=E6=99=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- context/output.go | 8 ++------ router.go | 4 ---- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/context/output.go b/context/output.go index d132e392..0a194753 100644 --- a/context/output.go +++ b/context/output.go @@ -66,7 +66,6 @@ func (output *BeegoOutput) Body(content []byte) { if val == "gzip" { output.Header("Content-Encoding", "gzip") outputWriter, _ = gzip.NewWriterLevel(output.Context.ResponseWriter, gzip.BestSpeed) - break } else if val == "deflate" { output.Header("Content-Encoding", "deflate") @@ -86,11 +85,8 @@ func (output *BeegoOutput) Body(content []byte) { } outputWriter.Write(content) - switch outputWriter.(type) { - case *gzip.Writer: - outputWriter.(*gzip.Writer).Close() - case *flate.Writer: - outputWriter.(*flate.Writer).Close() + if c, ok := outputWriter.(io.Closer); ok { + c.Close() } } diff --git a/router.go b/router.go index 1e8144bf..5c6b7bf9 100644 --- a/router.go +++ b/router.go @@ -897,10 +897,6 @@ type responseWriter struct { status int } -// Header returns the header map that will be sent by WriteHeader. -func (w *responseWriter) Header() http.Header { - return w.ResponseWriter.Header() -} // Write writes the data to the connection as part of an HTTP reply, // and sets `started` to true.