Skip to content

Commit e2419cf

Browse files
authored
Check error in BaseClient.Perform #922 (#926)
1 parent 7c663a6 commit e2419cf

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

elasticsearch.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,12 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) {
302302

303303
// Retrieve the original request.
304304
res, err := c.Transport.Perform(req)
305+
if err != nil {
306+
return nil, err
307+
}
305308

306309
// ResponseCheck path continues, we run the header check on the first answer from ES.
307-
if err == nil && (res.StatusCode >= 200 && res.StatusCode < 300){
310+
if res.StatusCode >= 200 && res.StatusCode < 300 {
308311
checkHeader := func(context.Context) error {
309312
return genuineCheckHeader(res.Header)
310313
}
@@ -313,7 +316,7 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) {
313316
return nil, err
314317
}
315318
}
316-
return res, err
319+
return res, nil
317320
}
318321

319322
// doProductCheck calls f if there as not been a prior successful call to doProductCheck,

0 commit comments

Comments
 (0)