回源跟随限制单次请求最大跳转次数为8

This commit is contained in:
刘祥超
2024-04-18 08:29:52 +08:00
parent 7130154bc8
commit 8794bf5676

View File

@@ -24,6 +24,7 @@ import (
var SharedHTTPClientPool = NewHTTPClientPool() var SharedHTTPClientPool = NewHTTPClientPool()
const httpClientProxyProtocolTag = "@ProxyProtocol@" const httpClientProxyProtocolTag = "@ProxyProtocol@"
const maxHTTPRedirects = 8
// HTTPClientPool 客户端池 // HTTPClientPool 客户端池
type HTTPClientPool struct { type HTTPClientPool struct {
@@ -212,8 +213,8 @@ func (this *HTTPClientPool) Client(req *HTTPRequest,
Timeout: readTimeout, Timeout: readTimeout,
Transport: transport, Transport: transport,
CheckRedirect: func(targetReq *http.Request, via []*http.Request) error { CheckRedirect: func(targetReq *http.Request, via []*http.Request) error {
// 是否跟随 // follow redirects
if followRedirects { if followRedirects && len(via) <= maxHTTPRedirects {
return nil return nil
} }