From a68e21e92ba74b9850a3cfda1a8a253b9c716d00 Mon Sep 17 00:00:00 2001 From: vitalii Date: Tue, 4 Sep 2018 23:48:06 +0300 Subject: [PATCH] requests: nil pointer dereference panic was fixed [#25] http.Do() method will return non-nil [error] in following cases: 1. Request is nil 2. Response missing Location header 3. Client failed to parse Location header 4. Method "request.GetBody()" returns error 5. Http.Client.Send() returns error 5. Client timeout was exceeded Signed-off-by: Christoph Polcin --- requests.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requests.go b/requests.go index 581c08c..cac0d8a 100644 --- a/requests.go +++ b/requests.go @@ -38,6 +38,9 @@ func (c *Client) req(method, path string, body io.Reader, intercept func(*http.R } rs, err := c.c.Do(r) + if err != nil { + return nil, err + } if rs.StatusCode == 401 && c.auth.Type() == "NoAuth" { if strings.Index(rs.Header.Get("Www-Authenticate"), "Digest") > -1 {