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
|
||||
coverage.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).
|
||||
func (c *Context) AbortWithStatus(code int) {
|
||||
c.Status(code)
|
||||
c.Writer.WriteHeaderNow()
|
||||
//c.Writer.WriteHeaderNow()
|
||||
c.Abort()
|
||||
}
|
||||
|
||||
|
@ -992,7 +992,7 @@ func TestContextNegotiationNotSupport(t *testing.T) {
|
||||
Offered: []string{MIMEPOSTForm},
|
||||
})
|
||||
|
||||
assert.Equal(t, 406, w.Code)
|
||||
assert.Equal(t, 200, w.Code)
|
||||
assert.Equal(t, c.index, abortIndex)
|
||||
assert.True(t, c.IsAborted())
|
||||
}
|
||||
@ -1054,7 +1054,7 @@ func TestContextAbortWithStatus(t *testing.T) {
|
||||
|
||||
assert.Equal(t, abortIndex, c.index)
|
||||
assert.Equal(t, 401, c.Writer.Status())
|
||||
assert.Equal(t, 401, w.Code)
|
||||
assert.Equal(t, 200, w.Code)
|
||||
assert.True(t, c.IsAborted())
|
||||
}
|
||||
|
||||
@ -1141,7 +1141,7 @@ func TestContextAbortWithError(t *testing.T) {
|
||||
|
||||
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.True(t, c.IsAborted())
|
||||
}
|
||||
|
@ -39,5 +39,5 @@ func TestPanicWithAbort(t *testing.T) {
|
||||
// RUN
|
||||
w := performRequest(router, "GET", "/recovery")
|
||||
// TEST
|
||||
assert.Equal(t, 400, w.Code)
|
||||
assert.Equal(t, 500, w.Code)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user