You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to do some works with goroutine in handler as the demo, and when I read the request body from copied context in goroutine, the reader always closed. the error detail is http: invalid Read on closed Body
How to reproduce
package main
import (
"github.com/gin-gonic/gin"
)
func main() {
g := gin.Default()
g.POST("/dosomething", func(c *gin.Context) {
cCp := c.Copy()
go func() {
var err error
var buf []byte
if buf, err = ioutil.ReadAll(cCp.Request.Body); err != nil {
log.Println(err)
return
}
fmt.Println(string(buf))
}()
})
g.Run(":9000")
}
Description
I try to do some works with goroutine in handler as the demo, and when I read the request body from copied context in goroutine, the reader always closed. the error detail is
http: invalid Read on closed Body
How to reproduce
Expectations
Actual result
Environment
The text was updated successfully, but these errors were encountered: