From 5da58d36bae88b5c10c0daa866a8c9a326ff1e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Saint-F=C3=A9lix?= Date: Wed, 27 Nov 2024 14:30:57 +0100 Subject: [PATCH] Check error in BaseClient.Perform #922 --- elasticsearch.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/elasticsearch.go b/elasticsearch.go index db204011c0..4168e4eb0e 100644 --- a/elasticsearch.go +++ b/elasticsearch.go @@ -302,9 +302,12 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) { // Retrieve the original request. res, err := c.Transport.Perform(req) + if err != nil { + return nil, err + } // ResponseCheck path continues, we run the header check on the first answer from ES. - if err == nil && (res.StatusCode >= 200 && res.StatusCode < 300){ + if res.StatusCode >= 200 && res.StatusCode < 300 { checkHeader := func(context.Context) error { return genuineCheckHeader(res.Header) } @@ -313,7 +316,7 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) { return nil, err } } - return res, err + return res, nil } // doProductCheck calls f if there as not been a prior successful call to doProductCheck,