beego:hotfix for multipart/form-data
Showing
1 changed file
with
4 additions
and
9 deletions
| ... | @@ -264,20 +264,15 @@ func (input *BeegoInput) SetData(key, val interface{}) { | ... | @@ -264,20 +264,15 @@ func (input *BeegoInput) SetData(key, val interface{}) { |
| 264 | input.Data[key] = val | 264 | input.Data[key] = val |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | // parseForm or parseMultiForm based on Content-type | ||
| 267 | func (input *BeegoInput) ParseFormOrMulitForm(maxMemory int64) error { | 268 | func (input *BeegoInput) ParseFormOrMulitForm(maxMemory int64) error { |
| 268 | // Parse the body depending on the content type. | 269 | // Parse the body depending on the content type. |
| 269 | switch input.Header("Content-Type") { | 270 | if strings.Contains(input.Header("Content-Type"), "multipart/form-data") { |
| 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": | ||
| 277 | if err := input.Request.ParseMultipartForm(maxMemory); err != nil { | 271 | if err := input.Request.ParseMultipartForm(maxMemory); err != nil { |
| 278 | return errors.New("Error parsing request body:" + err.Error()) | 272 | return errors.New("Error parsing request body:" + err.Error()) |
| 279 | } | 273 | } |
| 274 | } else if err := input.Request.ParseForm(); err != nil { | ||
| 275 | return errors.New("Error parsing request body:" + err.Error()) | ||
| 280 | } | 276 | } |
| 281 | |||
| 282 | return nil | 277 | return nil |
| 283 | } | 278 | } | ... | ... |
-
Please register or sign in to post a comment