1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-14 11:10:38 +00:00

fix 4224:form entity too large casue run out of memory

This commit is contained in:
Anker Jam
2020-10-18 23:18:13 +08:00
parent 140a4b90a3
commit c510926cb8
3 changed files with 12 additions and 5 deletions

View File

@ -420,10 +420,11 @@ func (input *BeegoInput) SetData(key, val interface{}) {
input.data[key] = val
}
// ParseFormOrMulitForm parseForm or parseMultiForm based on Content-type
func (input *BeegoInput) ParseFormOrMulitForm(maxMemory int64) error {
// ParseFormOrMultiForm parseForm or parseMultiForm based on Content-type
func (input *BeegoInput) ParseFormOrMultiForm(maxMemory int64) error {
// 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)
if err := input.Context.Request.ParseMultipartForm(maxMemory); err != nil {
return errors.New("Error parsing request body:" + err.Error())
}