From eb48e7de6024053068190eb8fe2bfb3123bdb1db Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Wed, 27 Jul 2016 09:11:34 -0700 Subject: [PATCH] Revert "fixed #604" This reverts commit 69e8c1e7178d296a0a432da53d976b72c4c19a5b. --- context.go | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/context.go b/context.go index 982a4292..cf579d96 100644 --- a/context.go +++ b/context.go @@ -338,27 +338,21 @@ func (c *echoContext) Render(code int, name string, data interface{}) (err error if err = c.echo.renderer.Render(buf, name, data, c); err != nil { return } - if c.response.Header().Get(HeaderContentType) == "" { - c.response.Header().Set(HeaderContentType, MIMETextHTMLCharsetUTF8) - } + c.response.Header().Set(HeaderContentType, MIMETextHTMLCharsetUTF8) c.response.WriteHeader(code) _, err = c.response.Write(buf.Bytes()) return } func (c *echoContext) HTML(code int, html string) (err error) { - if c.response.Header().Get(HeaderContentType) == "" { - c.response.Header().Set(HeaderContentType, MIMETextHTMLCharsetUTF8) - } + c.response.Header().Set(HeaderContentType, MIMETextHTMLCharsetUTF8) c.response.WriteHeader(code) _, err = c.response.Write([]byte(html)) return } func (c *echoContext) String(code int, s string) (err error) { - if c.response.Header().Get(HeaderContentType) == "" { - c.response.Header().Set(HeaderContentType, MIMETextPlainCharsetUTF8) - } + c.response.Header().Set(HeaderContentType, MIMETextPlainCharsetUTF8) c.response.WriteHeader(code) _, err = c.response.Write([]byte(s)) return @@ -376,9 +370,7 @@ func (c *echoContext) JSON(code int, i interface{}) (err error) { } func (c *echoContext) JSONBlob(code int, b []byte) (err error) { - if c.response.Header().Get(HeaderContentType) == "" { - c.response.Header().Set(HeaderContentType, MIMEApplicationJSONCharsetUTF8) - } + c.response.Header().Set(HeaderContentType, MIMEApplicationJSONCharsetUTF8) c.response.WriteHeader(code) _, err = c.response.Write(b) return @@ -389,9 +381,7 @@ func (c *echoContext) JSONP(code int, callback string, i interface{}) (err error if err != nil { return err } - if c.response.Header().Get(HeaderContentType) == "" { - c.response.Header().Set(HeaderContentType, MIMEApplicationJavaScriptCharsetUTF8) - } + c.response.Header().Set(HeaderContentType, MIMEApplicationJavaScriptCharsetUTF8) c.response.WriteHeader(code) if _, err = c.response.Write([]byte(callback + "(")); err != nil { return @@ -415,9 +405,7 @@ func (c *echoContext) XML(code int, i interface{}) (err error) { } func (c *echoContext) XMLBlob(code int, b []byte) (err error) { - if c.response.Header().Get(HeaderContentType) == "" { - c.response.Header().Set(HeaderContentType, MIMEApplicationXMLCharsetUTF8) - } + c.response.Header().Set(HeaderContentType, MIMEApplicationXMLCharsetUTF8) c.response.WriteHeader(code) if _, err = c.response.Write([]byte(xml.Header)); err != nil { return @@ -448,9 +436,7 @@ func (c *echoContext) File(file string) error { } func (c *echoContext) Attachment(r io.ReadSeeker, name string) (err error) { - if c.response.Header().Get(HeaderContentType) == "" { - c.response.Header().Set(HeaderContentType, ContentTypeByExtension(name)) - } + c.response.Header().Set(HeaderContentType, ContentTypeByExtension(name)) c.response.Header().Set(HeaderContentDisposition, "attachment; filename="+name) c.response.WriteHeader(http.StatusOK) _, err = io.Copy(c.response, r) @@ -501,9 +487,7 @@ func (c *echoContext) ServeContent(content io.ReadSeeker, name string, modtime t return c.NoContent(http.StatusNotModified) } - if c.response.Header().Get(HeaderContentType) == "" { - res.Header().Set(HeaderContentType, ContentTypeByExtension(name)) - } + res.Header().Set(HeaderContentType, ContentTypeByExtension(name)) res.Header().Set(HeaderLastModified, modtime.UTC().Format(http.TimeFormat)) res.WriteHeader(http.StatusOK) _, err := io.Copy(res, content)