Skip to content

Commit e307bd7

Browse files
committed
beego:hotfix for multipart/form-data
1 parent a99802b commit e307bd7

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

context/input.go

+4-9
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,15 @@ func (input *BeegoInput) SetData(key, val interface{}) {
264264
input.Data[key] = val
265265
}
266266

267+
// parseForm or parseMultiForm based on Content-type
267268
func (input *BeegoInput) ParseFormOrMulitForm(maxMemory int64) error {
268269
// Parse the body depending on the content type.
269-
switch input.Header("Content-Type") {
270-
case "application/x-www-form-urlencoded":
271-
// Typical form.
272-
if err := input.Request.ParseForm(); err != nil {
273-
return errors.New("Error parsing request body:" + err.Error())
274-
}
275-
276-
case "multipart/form-data":
270+
if strings.Contains(input.Header("Content-Type"), "multipart/form-data") {
277271
if err := input.Request.ParseMultipartForm(maxMemory); err != nil {
278272
return errors.New("Error parsing request body:" + err.Error())
279273
}
274+
} else if err := input.Request.ParseForm(); err != nil {
275+
return errors.New("Error parsing request body:" + err.Error())
280276
}
281-
282277
return nil
283278
}

0 commit comments

Comments
 (0)