소스 검색

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

Manu Mtz-Almeida 12 년 전
부모
커밋
2abbc4ad1d
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      gin.go

+ 1 - 1
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))
 }