Setting response headers before calling WriteHeader in context.String()

This commit is contained in:
Manu Mtz-Almeida 2014-07-02 01:47:32 +02:00
parent b0797e2bf9
commit 2abbc4ad1d
1 changed files with 1 additions and 1 deletions

2
gin.go
View File

@ -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))
}