- 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
I use function c.DefaultPostForm to get token param in the middleware, it cause a long time block with a slight possibility.
How to reproduce
func CheckTokenPro() gin.HandlerFunc {
return func(c *gin.Context) {
var token string
start := time.Now()
token = c.DefaultPostForm("token", "")
cost := time.Since(start).Seconds()
if cost > 3 {
logging.Info(fmt.Sprintf("CheckTokenPro:%.2f秒", cost))
}
c.Next()
}
}
Expectations
Actual result
Environment
- go version: 1.14.7
- gin version (or commit ref): gin v1.6.3
- operating system: linux
Comment From: mi-v
c.DefaultPostForm calls out to req.ParseMultipartForm, documentation of which says:
The whole request body is parsed and up to a total of maxMemory bytes of its file parts are stored in memory, with the remainder stored on disk in temporary files.
Which means that it has to read the whole request body from the network, and this may take some time depending on the request size and network speed.