mirror of
https://github.com/astaxie/beego.git
synced 2024-11-23 15:50:55 +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
|
// ParseFormOrMultiForm parseForm or parseMultiForm based on Content-type
|
||||||
func (input *BeegoInput) ParseFormOrMultiForm(maxMemory int64) error {
|
func (input *BeegoInput) ParseFormOrMultiForm(maxMemory int64) error {
|
||||||
// Parse the body depending on the content type.
|
// Parse the body depending on the content type.
|
||||||
if strings.Contains(input.Header("Content-Type"), "multipart/form-data") {
|
|
||||||
input.Context.Request.Body = http.MaxBytesReader(input.Context.ResponseWriter, input.Context.Request.Body, maxMemory)
|
input.Context.Request.Body = http.MaxBytesReader(input.Context.ResponseWriter, input.Context.Request.Body, maxMemory)
|
||||||
|
if strings.Contains(input.Header("Content-Type"), "multipart/form-data") {
|
||||||
if err := input.Context.Request.ParseMultipartForm(maxMemory); err != nil {
|
if err := input.Context.Request.ParseMultipartForm(maxMemory); err != nil {
|
||||||
return errors.New("Error parsing request body:" + err.Error())
|
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)
|
err = ctx.Input.ParseFormOrMultiForm(p.cfg.MaxMemory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error(errors.New("payload too large"))
|
logs.Error(err)
|
||||||
exception("413", ctx)
|
exception("413", ctx)
|
||||||
goto Admin
|
goto Admin
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user