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:
parent
c510926cb8
commit
cbb3de741d
@ -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())
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user