Преглед изворни кода

Do not update status code in Abort() if code is a negative number

Manu Mtz-Almeida пре 12 година
родитељ
комит
6da7374af5
1 измењених фајлова са 3 додато и 1 уклоњено
  1. 3 1
      gin.go

+ 3 - 1
gin.go

@@ -301,7 +301,9 @@ func (c *Context) Next() {
 // For example, the first handler checks if the request is authorized. If it's not, context.Abort(401) should be called.
 // The rest of pending handlers would never be called for that request.
 func (c *Context) Abort(code int) {
-	c.Writer.WriteHeader(code)
+	if code >= 0 {
+		c.Writer.WriteHeader(code)
+	}
 	c.index = AbortIndex
 }