From 47663aa1f1ed41916bc32b27e76cd914d19dcec1 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 13 Oct 2020 20:12:54 +0800 Subject: [PATCH] fix issue of EOF in ghttp.Request when no data posted using form-data --- net/ghttp/ghttp_request_param.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/ghttp/ghttp_request_param.go b/net/ghttp/ghttp_request_param.go index 91327bb32..8ad00ec0b 100644 --- a/net/ghttp/ghttp_request_param.go +++ b/net/ghttp/ghttp_request_param.go @@ -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/") {