From 88ec89bdbda24ef14e17a6b89d25dfd782c9c29d Mon Sep 17 00:00:00 2001 From: bittoy Date: Wed, 2 Dec 2020 15:00:07 +0800 Subject: [PATCH] optimization (#241) --- rest/httpx/requests.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/rest/httpx/requests.go b/rest/httpx/requests.go index bf217da5..8df8e712 100644 --- a/rest/httpx/requests.go +++ b/rest/httpx/requests.go @@ -10,7 +10,6 @@ import ( ) const ( - multipartFormData = "multipart/form-data" formKey = "form" pathKey = "path" emptyJson = "{}" @@ -39,12 +38,12 @@ func Parse(r *http.Request, v interface{}) error { // Parses the form request. func ParseForm(r *http.Request, v interface{}) error { - if strings.Contains(r.Header.Get(ContentType), multipartFormData) { - if err := r.ParseMultipartForm(maxMemory); err != nil { - return err - } - } else { - if err := r.ParseForm(); err != nil { + if err := r.ParseForm(); err != nil { + return err + } + + if err := r.ParseMultipartForm(maxMemory); err != nil { + if err != http.ErrNotMultipart { return err } }