Skip to content

Commit

Permalink
fix #3237 (#3267)
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn authored Jan 17, 2024
1 parent d26b7c5 commit 951f892
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion net/ghttp/ghttp_request_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,14 @@ func (r *Request) parseForm() {
return
}
if contentType := r.Header.Get("Content-Type"); contentType != "" {
var err error
var (
err error
repeatableRead = true
)
if gstr.Contains(contentType, "multipart/") {
// To avoid big memory consuming.
// The `multipart/` type form always contains binary data, which is not necessary read twice.
repeatableRead = false
// multipart/form-data, multipart/mixed
if err = r.ParseMultipartForm(r.Server.config.FormParsingMemory); err != nil {
panic(gerror.WrapCode(gcode.CodeInvalidRequest, err, "r.ParseMultipartForm failed"))
Expand All @@ -281,6 +287,9 @@ func (r *Request) parseForm() {
panic(gerror.WrapCode(gcode.CodeInvalidRequest, err, "r.Request.ParseForm failed"))
}
}
if repeatableRead {
r.MakeBodyRepeatableRead(true)
}
if len(r.PostForm) > 0 {
// Parse the form data using united parsing way.
params := ""
Expand Down
1 change: 1 addition & 0 deletions util/gconv/gconv_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func Map(value interface{}, option ...MapOption) map[string]interface{} {
// Deprecated: used Map instead.
func MapDeep(value interface{}, tags ...string) map[string]interface{} {
return doMapConvert(value, recursiveTypeTrue, false, MapOption{
Deep: true,
Tags: tags,
})
}
Expand Down

0 comments on commit 951f892

Please sign in to comment.