mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-23 18:22:23 +08:00
Merge 99f2da59c13a652a9fe6c398feba591271184e29 into 7a9a290b36bb803a18874aa5c5b108be2d7eb34d
This commit is contained in:
commit
a147bca4ee
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ vendor/*
|
|||||||
!vendor/vendor.json
|
!vendor/vendor.json
|
||||||
coverage.out
|
coverage.out
|
||||||
count.out
|
count.out
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ func (c *Context) Abort() {
|
|||||||
// For example, a failed attempt to authenticate a request could use: context.AbortWithStatus(401).
|
// For example, a failed attempt to authenticate a request could use: context.AbortWithStatus(401).
|
||||||
func (c *Context) AbortWithStatus(code int) {
|
func (c *Context) AbortWithStatus(code int) {
|
||||||
c.Status(code)
|
c.Status(code)
|
||||||
c.Writer.WriteHeaderNow()
|
//c.Writer.WriteHeaderNow()
|
||||||
c.Abort()
|
c.Abort()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -992,7 +992,7 @@ func TestContextNegotiationNotSupport(t *testing.T) {
|
|||||||
Offered: []string{MIMEPOSTForm},
|
Offered: []string{MIMEPOSTForm},
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.Equal(t, 406, w.Code)
|
assert.Equal(t, 200, w.Code)
|
||||||
assert.Equal(t, c.index, abortIndex)
|
assert.Equal(t, c.index, abortIndex)
|
||||||
assert.True(t, c.IsAborted())
|
assert.True(t, c.IsAborted())
|
||||||
}
|
}
|
||||||
@ -1054,7 +1054,7 @@ func TestContextAbortWithStatus(t *testing.T) {
|
|||||||
|
|
||||||
assert.Equal(t, abortIndex, c.index)
|
assert.Equal(t, abortIndex, c.index)
|
||||||
assert.Equal(t, 401, c.Writer.Status())
|
assert.Equal(t, 401, c.Writer.Status())
|
||||||
assert.Equal(t, 401, w.Code)
|
assert.Equal(t, 200, w.Code)
|
||||||
assert.True(t, c.IsAborted())
|
assert.True(t, c.IsAborted())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1141,7 +1141,7 @@ func TestContextAbortWithError(t *testing.T) {
|
|||||||
|
|
||||||
c.AbortWithError(401, errors.New("bad input")).SetMeta("some input")
|
c.AbortWithError(401, errors.New("bad input")).SetMeta("some input")
|
||||||
|
|
||||||
assert.Equal(t, 401, w.Code)
|
assert.Equal(t, 200, w.Code)
|
||||||
assert.Equal(t, abortIndex, c.index)
|
assert.Equal(t, abortIndex, c.index)
|
||||||
assert.True(t, c.IsAborted())
|
assert.True(t, c.IsAborted())
|
||||||
}
|
}
|
||||||
|
@ -39,5 +39,5 @@ func TestPanicWithAbort(t *testing.T) {
|
|||||||
// RUN
|
// RUN
|
||||||
w := performRequest(router, "GET", "/recovery")
|
w := performRequest(router, "GET", "/recovery")
|
||||||
// TEST
|
// TEST
|
||||||
assert.Equal(t, 400, w.Code)
|
assert.Equal(t, 500, w.Code)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user