app/vmauth: use slices.Contains() instead of hasInt()

This commit is contained in:
Aliaksandr Valialkin 2024-03-06 17:35:38 +02:00
parent 76a6f806ae
commit 96f913c83e
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB

View file

@ -13,6 +13,7 @@ import (
"net/textproto"
"net/url"
"os"
"slices"
"strings"
"sync"
"time"
@ -271,7 +272,7 @@ func tryProcessingRequest(w http.ResponseWriter, r *http.Request, targetURL *url
logger.Warnf("remoteAddr: %s; requestURI: %s; retrying the request to %s because of response error: %s", remoteAddr, req.URL, targetURL, err)
return false
}
if hasInt(retryStatusCodes, res.StatusCode) {
if slices.Contains(retryStatusCodes, res.StatusCode) {
_ = res.Body.Close()
if !rtbOK || !rtb.canRetry() {
// If we get an error from the retry_status_codes list, but cannot execute retry,
@ -313,15 +314,6 @@ func tryProcessingRequest(w http.ResponseWriter, r *http.Request, targetURL *url
return true
}
func hasInt(a []int, n int) bool {
for _, x := range a {
if x == n {
return true
}
}
return false
}
var copyBufPool bytesutil.ByteBufferPool
func copyHeader(dst, src http.Header) {