- With issues:
- Use the search tool before opening a new issue.
- Please provide source code and commit sha if you found a bug.
- Review existing issues and provide feedback or react to them.
Description
http: wrote more than the declared Content-Length
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/render/json.go:59 (0x925946)
JSON.Render: panic(err)
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:841 (0x92c2a8)
(*Context).Render: if err := r.Render(c.Writer); err != nil {
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:884 (0xb42348)
(*Context).JSON: c.Render(code, render.JSON{Data: obj})
/home/debian/xiehui-blog/controllers/base/baseController.go:44 (0xb42270)
(*BaseController).Result: bc.Ctx.JSON(http.StatusOK, Response{
/home/debian/xiehui-blog/controllers/admin/indexRestApi.go:228 (0xb42265)
(*IndexRestApi).GetBlogContributeCount: c.Result("success", tempMap)
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xb178d5)
(*Context).Next: c.handlersc.index
/home/debian/go/pkg/mod/github.com/gin-contrib/[email protected]/sessions.go:52 (0xb178bd)
Sessions.func1: c.Next()
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xb2fde6)
(*Context).Next: c.handlersc.index
/home/debian/xiehui-blog/middleware/loger.go:106 (0xb2fda5)
LoggerToFile.func1: c.Next()
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0x93be30)
(*Context).Next: c.handlersc.index
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:83 (0x93be17)
RecoveryWithWriter.func1: c.Next()
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0x93aeb3)
(*Context).Next: c.handlersc.index
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:241 (0x93ae72)
LoggerWithConfig.func1: c.Next()
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xb6dc75)
(*Context).Next: c.handlersc.index
/home/debian/xiehui-blog/routers/router.go:200 (0xb6dc57)
Cors2.func1: c.Next()
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0x931fef)
(*Context).Next: c.handlersc.index
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:409 (0x931fd6)
(*Engine).handleHTTPRequest: c.Next()
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:367 (0x931a8c)
(*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/snap/go/7221/src/net/http/server.go:2887 (0x6b2982)
serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/snap/go/7221/src/net/http/server.go:1952 (0x6addac)
(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/snap/go/7221/src/runtime/asm_amd64.s:1371 (0x46db20)
goexit: BYTE $0x90 // NOP
How to reproduce
type BaseController struct {
Ctx *gin.Context
}
type ClassifyRestApi struct {
BaseController
}
func (bc *ClassifyRestApi) GetList(ctx *gin.Context) {
bc.Ctx = ctx
var ProList []models.Product
common.DB.Where("status=?", 1).Order("sort desc").Find(& ProList)
bc.Ctx.JSON(http.StatusOK, gin.H{
"Code": "code",
"Data": ProList,
})
}
Expectations
Environment
- go version:go version go1.13.8 linux/amd64
- gin version (or commit ref):github.com/gin-gonic/gin v1.6.3 // indirect
- operating system: Operating System: Linux Mint 20.1
Kernel: Linux 5.4.0-66-generic
Description
http: wrote more than the declared Content-Length
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/render/json.go:59 (0x925946)
JSON.Render: panic(err)
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:841 (0x92c2a8)
(*Context).Render: if err := r.Render(c.Writer); err != nil {
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:884 (0xb42348)
(*Context).JSON: c.Render(code, render.JSON{Data: obj})
/home/debian/xiehui-blog/controllers/base/baseController.go:44 (0xb42270)
(*BaseController).Result: bc.Ctx.JSON(http.StatusOK, Response{
/home/debian/xiehui-blog/controllers/admin/indexRestApi.go:228 (0xb42265)
(*IndexRestApi).GetBlogContributeCount: c.Result("success", tempMap)
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xb178d5)
(*Context).Next: c.handlersc.index
/home/debian/go/pkg/mod/github.com/gin-contrib/[email protected]/sessions.go:52 (0xb178bd)
Sessions.func1: c.Next()
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xb2fde6)
(*Context).Next: c.handlersc.index
/home/debian/xiehui-blog/middleware/loger.go:106 (0xb2fda5)
LoggerToFile.func1: c.Next()
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0x93be30)
(*Context).Next: c.handlersc.index
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:83 (0x93be17)
RecoveryWithWriter.func1: c.Next()
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0x93aeb3)
(*Context).Next: c.handlersc.index
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:241 (0x93ae72)
LoggerWithConfig.func1: c.Next()
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xb6dc75)
(*Context).Next: c.handlersc.index
/home/debian/xiehui-blog/routers/router.go:200 (0xb6dc57)
Cors2.func1: c.Next()
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0x931fef)
(*Context).Next: c.handlersc.index
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:409 (0x931fd6)
(*Engine).handleHTTPRequest: c.Next()
/home/debian/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:367 (0x931a8c)
(*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/snap/go/7221/src/net/http/server.go:2887 (0x6b2982)
serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/snap/go/7221/src/net/http/server.go:1952 (0x6addac)
(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/snap/go/7221/src/runtime/asm_amd64.s:1371 (0x46db20)
goexit: BYTE $0x90 // NOP
How to reproduce
Expectations
Environment
Kernel: Linux 5.4.0-66-generic