From 2abbc4ad1dc5b5b606861501c1f2d3195a570295 Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Wed, 2 Jul 2014 01:47:32 +0200 Subject: [PATCH] Setting response headers before calling WriteHeader in context.String() --- gin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gin.go b/gin.go index fc5da8c..66530d2 100644 --- a/gin.go +++ b/gin.go @@ -344,8 +344,8 @@ func (c *Context) HTML(code int, name string, data interface{}) { // Writes the given string into the response body and sets the Content-Type to "text/plain" func (c *Context) String(code int, msg string) { - c.Writer.Header().Set("Content-Type", "text/plain") c.Writer.WriteHeader(code) + c.Writer.Header().Set("Content-Type", "text/plain") c.Writer.Write([]byte(msg)) }