mirror of
https://github.com/gin-gonic/gin.git
synced 2026-05-04 10:08:11 +08:00
Use http.StatusContinue constant instead of magic number 100
Replace magic number `100` with `http.StatusContinue` constant for better code clarity and maintainability in `bodyAllowedForStatus` function. Fixes #4489
This commit is contained in:
parent
71cefce08e
commit
7f07058407
@ -1056,6 +1056,7 @@ func (c *Context) requestHeader(key string) string {
|
||||
/************************************/
|
||||
|
||||
// bodyAllowedForStatus is a copy of http.bodyAllowedForStatus non-exported function.
|
||||
// Use http.StatusContinue constant for better code clarity
|
||||
func bodyAllowedForStatus(status int) bool {
|
||||
switch {
|
||||
case status >= http.StatusContinue && status < http.StatusOK:
|
||||
|
||||
@ -1033,6 +1033,7 @@ func TestContextGetCookie(t *testing.T) {
|
||||
func TestContextBodyAllowedForStatus(t *testing.T) {
|
||||
assert.False(t, bodyAllowedForStatus(http.StatusProcessing))
|
||||
assert.False(t, bodyAllowedForStatus(http.StatusNoContent))
|
||||
assert.False(t, bodyAllowedForStatus(http.StatusContinue))
|
||||
assert.False(t, bodyAllowedForStatus(http.StatusNotModified))
|
||||
assert.True(t, bodyAllowedForStatus(http.StatusInternalServerError))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user