Skip to content

Commit d1bc209

Browse files
authored
Client: Validate product only on successful responses (#371)
1 parent 368c0bd commit d1bc209

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

elasticsearch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) {
304304
res, err := c.Transport.Perform(req)
305305

306306
// ResponseCheck path continues, we run the header check on the first answer from ES.
307-
if err == nil {
307+
if err == nil && (res.StatusCode >= 200 && res.StatusCode < 300){
308308
checkHeader := func(context.Context) error {
309309
return genuineCheckHeader(res.Header)
310310
}

elasticsearch_internal_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ func TestResponseCheckOnly(t *testing.T) {
630630
name: "Valid answer without header and response check",
631631
useResponseCheckOnly: true,
632632
response: &http.Response{
633+
StatusCode: http.StatusOK,
633634
Body: ioutil.NopCloser(strings.NewReader("{}")),
634635
},
635636
wantErr: true,

0 commit comments

Comments
 (0)