Skip to content

Commit 8e7635a

Browse files
committed
Handle 500 status code & ITATS error code
1 parent 86403b5 commit 8e7635a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/cybr/helpers/httpjson/httpjson.go

+8
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ func SendRequestRaw(ctx context.Context, identity bool, url string, method strin
180180
return ctx, nil, fmt.Errorf("Failed to read body. %v", err)
181181
}
182182

183+
// Check if the response status code is 500 and look for the error message ITATS542I
184+
if res.StatusCode == 500 && bytes.Contains(content, []byte("ITATS542I")) {
185+
newCtx := context.WithValue(ctx, contextKeyCookies, res.Cookies())
186+
return newCtx, content, err
187+
} else if res.StatusCode >= 300 {
188+
return ctx, nil, fmt.Errorf("Received non-200 status code '%d'", res.StatusCode)
189+
}
190+
183191
newCtx := context.WithValue(ctx, contextKeyCookies, res.Cookies())
184192
return newCtx, content, err
185193

0 commit comments

Comments
 (0)