@@ -1081,6 +1081,7 @@ https://github.com/Tencent/APIJSON/issues
1081
1081
scriptType : 'case' ,
1082
1082
scriptBelongId : 0 ,
1083
1083
scripts : newDefaultScript ( ) ,
1084
+ retry : 0 , // 每个请求前的等待延迟
1084
1085
wait : 0 , // 每个请求前的等待延迟
1085
1086
timeout : null , // 每个请求的超时时间
1086
1087
loadingCount : 0 ,
@@ -6427,7 +6428,7 @@ https://github.com/Tencent/APIJSON/issues
6427
6428
} ,
6428
6429
6429
6430
//请求
6430
- request : function ( isAdminOperation , method , type , url , req , header , callback , caseScript_ , accountScript_ , globalScript_ , ignorePreScript , timeout_ , wait_ ) {
6431
+ request : function ( isAdminOperation , method , type , url , req , header , callback , caseScript_ , accountScript_ , globalScript_ , ignorePreScript , timeout_ , wait_ , retry_ ) {
6431
6432
this . loadingCount ++
6432
6433
6433
6434
const isEnvCompare = this . isEnvCompareEnabled
@@ -6438,6 +6439,24 @@ https://github.com/Tencent/APIJSON/issues
6438
6439
const caseScript = ( isAdminOperation ? null : caseScript_ ) || { }
6439
6440
const timeout = timeout_ != null ? timeout_ : this . timeout
6440
6441
const wait = wait_ != null ? wait_ : ( this . wait || 0 )
6442
+ var retry = retry_ != null ? retry_ : ( this . retry || 0 )
6443
+ var retryReq = function ( ) {
6444
+ if ( retry == null || retry <= 0 ) {
6445
+ return false
6446
+ }
6447
+
6448
+ retry --
6449
+ try {
6450
+ sendRequest ( isAdminOperation , method , type , url , req , header , callback )
6451
+ } catch ( e ) {
6452
+ App . log ( 'request retryReq retry = ' + retry + ' >> try {\n' +
6453
+ ' sendRequest(isAdminOperation, method, type, url, req, header, callback)\n' +
6454
+ ' } catch (e) = ' + e . message )
6455
+ return retryReq ( )
6456
+ }
6457
+
6458
+ return true
6459
+ }
6441
6460
6442
6461
var evalPostScript = function ( ) { }
6443
6462
@@ -6558,6 +6577,10 @@ https://github.com/Tencent/APIJSON/issues
6558
6577
App . onResponse ( url , res , null )
6559
6578
} )
6560
6579
. catch ( function ( err ) {
6580
+ if ( retryReq ( ) ) {
6581
+ return ;
6582
+ }
6583
+
6561
6584
var errObj = err instanceof Array == false && err instanceof Object ? err : { }
6562
6585
var res = { status : errObj . status || ( errObj . response || { } ) . status , request : { url : url , headers : header , data : req } , data : ( errObj . response || { } ) . data }
6563
6586
App . currentHttpResponse = res
0 commit comments