Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 8.17] Check error in BaseClient.Perform (#922) #927

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,17 +341,20 @@ func (c *BaseClient) Perform(req *http.Request) (*http.Response, error) {

// Retrieve the original request.
res, err := c.Transport.Perform(req)
if err != nil {
return nil, err
}

// ResponseCheck, 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() error { return genuineCheckHeader(res.Header) }
if err := c.doProductCheck(checkHeader); err != nil {
res.Body.Close()
return nil, err
}
}

return res, err
return res, nil
}

// InstrumentationEnabled propagates back to the client the Instrumentation provided by the transport.
Expand Down