From ed8068de6ea9bccd36e03db6a6bf932804b99ed9 Mon Sep 17 00:00:00 2001 From: Jeevanandam M Date: Sun, 10 May 2020 19:31:54 -0700 Subject: [PATCH] GH #330 Addressing nil pointer error while accessing cookie jar on user provided http client --- util.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/util.go b/util.go index a247be46..aaa53c23 100644 --- a/util.go +++ b/util.go @@ -297,11 +297,13 @@ func composeHeaders(c *Client, r *Request, hdrs http.Header) string { var v string if k == "Cookie" { cv := strings.TrimSpace(strings.Join(hdrs[k], ", ")) - for _, c := range c.GetClient().Jar.Cookies(r.RawRequest.URL) { - if cv != "" { - cv = cv + "; " + c.String() - } else { - cv = c.String() + if c.GetClient().Jar != nil { + for _, c := range c.GetClient().Jar.Cookies(r.RawRequest.URL) { + if cv != "" { + cv = cv + "; " + c.String() + } else { + cv = c.String() + } } } v = strings.TrimSpace(fmt.Sprintf("%25s: %s", k, cv))