Skip to content

Commit a88dfb8

Browse files
committed
fix(net/ghttp) parseForm MakeBodyRepeatableRead not effective
1 parent 20b1987 commit a88dfb8

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

net/ghttp/ghttp_request_param.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,13 @@ func (r *Request) parseForm() {
269269
return
270270
}
271271
if contentType := r.Header.Get("Content-Type"); contentType != "" {
272-
var (
273-
err error
274-
repeatableRead = true
275-
)
276-
if gstr.Contains(contentType, "multipart/") {
272+
var err error
273+
if !gstr.Contains(contentType, "multipart/") {
277274
// To avoid big memory consuming.
278275
// The `multipart/` type form always contains binary data, which is not necessary read twice.
279-
repeatableRead = false
276+
r.MakeBodyRepeatableRead(true)
277+
}
278+
if gstr.Contains(contentType, "multipart/") {
280279
// multipart/form-data, multipart/mixed
281280
if err = r.ParseMultipartForm(r.Server.config.FormParsingMemory); err != nil {
282281
panic(gerror.WrapCode(gcode.CodeInvalidRequest, err, "r.ParseMultipartForm failed"))
@@ -287,9 +286,6 @@ func (r *Request) parseForm() {
287286
panic(gerror.WrapCode(gcode.CodeInvalidRequest, err, "r.Request.ParseForm failed"))
288287
}
289288
}
290-
if repeatableRead {
291-
r.MakeBodyRepeatableRead(true)
292-
}
293289
if len(r.PostForm) > 0 {
294290
// Parse the form data using united parsing way.
295291
params := ""

0 commit comments

Comments
 (0)