1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-23 15:50:49 +00:00

fix application/x-www-form-urlencoded request body oversize

This commit is contained in:
Anker Jam 2020-10-18 23:38:08 +08:00
parent c510926cb8
commit cbb3de741d
2 changed files with 2 additions and 2 deletions

View File

@ -423,8 +423,8 @@ func (input *BeegoInput) SetData(key, val interface{}) {
// ParseFormOrMultiForm parseForm or parseMultiForm based on Content-type
func (input *BeegoInput) ParseFormOrMultiForm(maxMemory int64) error {
// Parse the body depending on the content type.
input.Context.Request.Body = http.MaxBytesReader(input.Context.ResponseWriter, input.Context.Request.Body, maxMemory)
if strings.Contains(input.Header("Content-Type"), "multipart/form-data") {
input.Context.Request.Body = http.MaxBytesReader(input.Context.ResponseWriter, input.Context.Request.Body, maxMemory)
if err := input.Context.Request.ParseMultipartForm(maxMemory); err != nil {
return errors.New("Error parsing request body:" + err.Error())
}

View File

@ -722,7 +722,7 @@ func (p *ControllerRegister) serveHttp(ctx *beecontext.Context) {
err = ctx.Input.ParseFormOrMultiForm(p.cfg.MaxMemory)
if err != nil {
logs.Error(errors.New("payload too large"))
logs.Error(err)
exception("413", ctx)
goto Admin
}