From 1e4a9c43d2cd6f36cac962f6519ec25be7a5347a Mon Sep 17 00:00:00 2001 From: Joseph Herlant Date: Tue, 3 Apr 2018 16:46:55 -0700 Subject: [PATCH] EndStruct: Allow empty body not to return json failure --- gorequest.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gorequest.go b/gorequest.go index 8edb0fc..b5e50de 100644 --- a/gorequest.go +++ b/gorequest.go @@ -1024,10 +1024,12 @@ func (s *SuperAgent) EndStruct(v interface{}, callback ...func(response Response if errs != nil { return nil, body, errs } - err := json.Unmarshal(body, &v) - if err != nil { - s.Errors = append(s.Errors, err) - return resp, body, s.Errors + if len(body) != 0 { + err := json.Unmarshal(body, &v) + if err != nil { + s.Errors = append(s.Errors, err) + return resp, body, s.Errors + } } respCallback := *resp if len(callback) != 0 {