From e307bd7ba933c7bf3920a8bcedd7e32dce1d376a Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 15 Apr 2014 05:05:53 +0800 Subject: [PATCH] beego:hotfix for multipart/form-data --- context/input.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/context/input.go b/context/input.go index ae62c8c7..ee192d7f 100644 --- a/context/input.go +++ b/context/input.go @@ -264,20 +264,15 @@ func (input *BeegoInput) SetData(key, val interface{}) { input.Data[key] = val } +// parseForm or parseMultiForm based on Content-type func (input *BeegoInput) ParseFormOrMulitForm(maxMemory int64) error { // Parse the body depending on the content type. - switch input.Header("Content-Type") { - case "application/x-www-form-urlencoded": - // Typical form. - if err := input.Request.ParseForm(); err != nil { - return errors.New("Error parsing request body:" + err.Error()) - } - - case "multipart/form-data": + if strings.Contains(input.Header("Content-Type"), "multipart/form-data") { if err := input.Request.ParseMultipartForm(maxMemory); err != nil { return errors.New("Error parsing request body:" + err.Error()) } + } else if err := input.Request.ParseForm(); err != nil { + return errors.New("Error parsing request body:" + err.Error()) } - return nil }