@@ -34,8 +34,7 @@ public sealed class HttpClient
3434 private static Object syncInstance = new Object ( ) ;
3535
3636 private const int MAX_ACTIVIE_TASKS = 5 ;
37-
38- public int MaxRetry { private get ; set ; } = 3 ;
37+
3938
4039 private volatile int activieTasks = 0 ;
4140
@@ -146,7 +145,7 @@ public void InternalExcute(CosRequest cosRequest, CosResult cosResult, QCloudCre
146145 catch ( CosServerException serverException )
147146 {
148147 // 状态码为301/302/307时,满足域名切换条件(域名匹配myqcloud.com & 响应不含cos requestid & 开启域名切换开关)时,进行3次重试;其余不重试
149- if ( retryIndex < MaxRetry &&
148+ if ( retryIndex < cosRequest . MaxRetry &&
150149 ( serverException . statusCode == 301 || serverException . statusCode == 302 || serverException . statusCode == 307 ) )
151150 {
152151 if ( request . Host . Contains ( "myqcloud.com" ) && serverException . requestId == String . Empty )
@@ -156,9 +155,9 @@ public void InternalExcute(CosRequest cosRequest, CosResult cosResult, QCloudCre
156155 cosRequest . SetRequestHeader ( "x-cos-sdk-retry" , "true" ) ;
157156 InternalExcute ( cosRequest , cosResult , credentialProvider , retryIndex + 1 ) ;
158157 }
159- else if ( retryIndex < MaxRetry && serverException . statusCode >= 500 )
158+ else if ( retryIndex < cosRequest . MaxRetry && serverException . statusCode >= 500 )
160159 {
161- if ( retryIndex == MaxRetry - 1 )
160+ if ( retryIndex == cosRequest . MaxRetry - 1 || ! cosRequest . RetryKeepDefaultDomain ) //最后一次切换域名
162161 {
163162 cosRequest . RetryUseBackupDomain = true ;
164163 }
0 commit comments