fix issue of EOF in ghttp.Request when no data posted using form-data

This commit is contained in:
John
2020-10-13 20:12:54 +08:00
parent 63c0aab19c
commit 47663aa1f1

View File

@ -276,6 +276,10 @@ func (r *Request) parseBody() {
return
}
r.parsedBody = true
// There's no data posted.
if r.ContentLength == 0 {
return
}
if body := r.GetBody(); len(body) > 0 {
// Trim space/new line characters.
body = bytes.TrimSpace(body)
@ -306,6 +310,10 @@ func (r *Request) parseForm() {
return
}
r.parsedForm = true
// There's no data posted.
if r.ContentLength == 0 {
return
}
if contentType := r.Header.Get("Content-Type"); contentType != "" {
var err error
if gstr.Contains(contentType, "multipart/") {