Do not update header when status code is less than 1

This commit is contained in:
Manu Mtz-Almeida 2014-07-02 01:50:33 +02:00
parent 2abbc4ad1d
commit 4b62957d85

2
gin.go
View File

@ -344,7 +344,9 @@ 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" // Writes the given string into the response body and sets the Content-Type to "text/plain"
func (c *Context) String(code int, msg string) { func (c *Context) String(code int, msg string) {
if code >= 0 {
c.Writer.WriteHeader(code) c.Writer.WriteHeader(code)
}
c.Writer.Header().Set("Content-Type", "text/plain") c.Writer.Header().Set("Content-Type", "text/plain")
c.Writer.Write([]byte(msg)) c.Writer.Write([]byte(msg))
} }