context: fix multipart/form-data
Showing
1 changed file
with
3 additions
and
9 deletions
| ... | @@ -274,19 +274,13 @@ func (input *BeegoInput) SetData(key, val interface{}) { | ... | @@ -274,19 +274,13 @@ func (input *BeegoInput) SetData(key, val interface{}) { |
| 274 | // parseForm or parseMultiForm based on Content-type | 274 | // parseForm or parseMultiForm based on Content-type |
| 275 | func (input *BeegoInput) ParseFormOrMulitForm(maxMemory int64) error { | 275 | func (input *BeegoInput) ParseFormOrMulitForm(maxMemory int64) error { |
| 276 | // Parse the body depending on the content type. | 276 | // Parse the body depending on the content type. |
| 277 | switch input.Header("Content-Type") { | 277 | if strings.Contains(input.Header("Content-Type"), "multipart/form-data") { |
| 278 | case "application/x-www-form-urlencoded": | ||
| 279 | // Typical form. | ||
| 280 | if err := input.Request.ParseForm(); err != nil { | ||
| 281 | return errors.New("Error parsing request body:" + err.Error()) | ||
| 282 | } | ||
| 283 | |||
| 284 | case "multipart/form-data": | ||
| 285 | if err := input.Request.ParseMultipartForm(maxMemory); err != nil { | 278 | if err := input.Request.ParseMultipartForm(maxMemory); err != nil { |
| 286 | return errors.New("Error parsing request body:" + err.Error()) | 279 | return errors.New("Error parsing request body:" + err.Error()) |
| 287 | } | 280 | } |
| 281 | } else if err := input.Request.ParseForm(); err != nil { | ||
| 282 | return errors.New("Error parsing request body:" + err.Error()) | ||
| 288 | } | 283 | } |
| 289 | |||
| 290 | return nil | 284 | return nil |
| 291 | } | 285 | } |
| 292 | 286 | ... | ... |
-
Please register or sign in to post a comment