@@ -6755,6 +6755,210 @@ group('RawBody error', function () {
67556755 } ) ;
67566756} ) ;
67576757
6758+ group ( 'retry myqcloud.com' , function ( ) {
6759+ const cos = new COS ( {
6760+ SecretId : config . SecretId ,
6761+ SecretKey : config . SecretKey ,
6762+ Protocol : 'http' ,
6763+ AutoSwitchHost : false ,
6764+ Timeout : 10000 ,
6765+ } ) ;
6766+ const config = {
6767+ Bucket : 'cos-sdk-err-retry-1253960454' ,
6768+ Region : 'ap-chengdu' ,
6769+ } ;
6770+ function getObject ( Key , done , expectErr ) {
6771+ cos . getObject (
6772+ {
6773+ Bucket : config . Bucket ,
6774+ Region : config . Region ,
6775+ Key,
6776+ } ,
6777+ function ( err , data ) {
6778+ const isOk = expectErr ? err : ! err ;
6779+ console . log ( `retry ${ Key } ---res` , err ? 'err' : 'success' , isOk ) ;
6780+ assert . ok ( isOk ) ;
6781+ done ( ) ;
6782+ }
6783+ ) ;
6784+ }
6785+ test ( 'get 200' , function ( done ) {
6786+ getObject ( '200' , done ) ;
6787+ } ) ;
6788+ test ( 'get 200r' , function ( done ) {
6789+ getObject ( '200r' , done ) ;
6790+ } ) ;
6791+ test ( 'get 204' , function ( done ) {
6792+ getObject ( '204' , done ) ;
6793+ } ) ;
6794+ test ( 'get 204r' , function ( done ) {
6795+ getObject ( '204r' , done ) ;
6796+ } ) ;
6797+ test ( 'get 206' , function ( done ) {
6798+ getObject ( '206' , done ) ;
6799+ } ) ;
6800+ test ( 'get 206r' , function ( done ) {
6801+ getObject ( '206r' , done ) ;
6802+ } ) ;
6803+ test ( 'get 301' , function ( done ) {
6804+ getObject ( '301' , done , true ) ;
6805+ } ) ;
6806+ test ( 'get 301r' , function ( done ) {
6807+ getObject ( '301r' , done , true ) ;
6808+ } ) ;
6809+ test ( 'get 302' , function ( done ) {
6810+ getObject ( '302' , done , true ) ;
6811+ } ) ;
6812+ test ( 'get 302r' , function ( done ) {
6813+ getObject ( '302r' , done , true ) ;
6814+ } ) ;
6815+ test ( 'get 400' , function ( done ) {
6816+ getObject ( '400' , done , true ) ;
6817+ } ) ;
6818+ test ( 'get 400r' , function ( done ) {
6819+ getObject ( '400r' , done , true ) ;
6820+ } ) ;
6821+ test ( 'get 403' , function ( done ) {
6822+ getObject ( '403' , done , true ) ;
6823+ } ) ;
6824+ test ( 'get 403r' , function ( done ) {
6825+ getObject ( '403r' , done , true ) ;
6826+ } ) ;
6827+ test ( 'get 404' , function ( done ) {
6828+ getObject ( '404' , done , true ) ;
6829+ } ) ;
6830+ test ( 'get 404r' , function ( done ) {
6831+ getObject ( '404r' , done , true ) ;
6832+ } ) ;
6833+ test ( 'get 500' , function ( done ) {
6834+ getObject ( '500' , done ) ;
6835+ } ) ;
6836+ test ( 'get 500r' , function ( done ) {
6837+ getObject ( '500r' , done ) ;
6838+ } ) ;
6839+ test ( 'get 503' , function ( done ) {
6840+ getObject ( '503' , done ) ;
6841+ } ) ;
6842+ test ( 'get 503r' , function ( done ) {
6843+ getObject ( '503r' , done ) ;
6844+ } ) ;
6845+ test ( 'get 504' , function ( done ) {
6846+ getObject ( '504' , done ) ;
6847+ } ) ;
6848+ test ( 'get 504r' , function ( done ) {
6849+ getObject ( '504r' , done ) ;
6850+ } ) ;
6851+ test ( 'get shutdown' , function ( done ) {
6852+ getObject ( 'shutdown' , done ) ;
6853+ } ) ;
6854+ test ( 'get timeout' , function ( done ) {
6855+ getObject ( 'timeout' , done ) ;
6856+ } ) ;
6857+ } ) ;
6858+
6859+ group ( 'retry tencentcos.cn' , function ( ) {
6860+ const cos = new COS ( {
6861+ SecretId : config . SecretId ,
6862+ SecretKey : config . SecretKey ,
6863+ Protocol : 'http' ,
6864+ AutoSwitchHost : false ,
6865+ Timeout : 10000 ,
6866+ Domain : '{Bucket}.cos.{Region}.tencentcos.cn' ,
6867+ } ) ;
6868+ const config = {
6869+ Bucket : 'cos-sdk-err-retry-1253960454' ,
6870+ Region : 'ap-chengdu' ,
6871+ } ;
6872+ function getObject ( Key , done , expectErr ) {
6873+ cos . getObject (
6874+ {
6875+ Bucket : config . Bucket ,
6876+ Region : config . Region ,
6877+ Key,
6878+ } ,
6879+ function ( err , data ) {
6880+ const isOk = expectErr ? err : ! err ;
6881+ console . log ( `retry ${ Key } ---res` , err ? 'err' : 'success' , isOk ) ;
6882+ assert . ok ( isOk ) ;
6883+ done ( ) ;
6884+ }
6885+ ) ;
6886+ }
6887+ test ( 'get 200' , function ( done ) {
6888+ getObject ( '200' , done ) ;
6889+ } ) ;
6890+ test ( 'get 200r' , function ( done ) {
6891+ getObject ( '200r' , done ) ;
6892+ } ) ;
6893+ test ( 'get 204' , function ( done ) {
6894+ getObject ( '204' , done ) ;
6895+ } ) ;
6896+ test ( 'get 204r' , function ( done ) {
6897+ getObject ( '204r' , done ) ;
6898+ } ) ;
6899+ test ( 'get 206' , function ( done ) {
6900+ getObject ( '206' , done ) ;
6901+ } ) ;
6902+ test ( 'get 206r' , function ( done ) {
6903+ getObject ( '206r' , done ) ;
6904+ } ) ;
6905+ test ( 'get 301' , function ( done ) {
6906+ getObject ( '301' , done , true ) ;
6907+ } ) ;
6908+ test ( 'get 301r' , function ( done ) {
6909+ getObject ( '301r' , done , true ) ;
6910+ } ) ;
6911+ test ( 'get 302' , function ( done ) {
6912+ getObject ( '302' , done , true ) ;
6913+ } ) ;
6914+ test ( 'get 302r' , function ( done ) {
6915+ getObject ( '302r' , done , true ) ;
6916+ } ) ;
6917+ test ( 'get 400' , function ( done ) {
6918+ getObject ( '400' , done , true ) ;
6919+ } ) ;
6920+ test ( 'get 400r' , function ( done ) {
6921+ getObject ( '400r' , done , true ) ;
6922+ } ) ;
6923+ test ( 'get 403' , function ( done ) {
6924+ getObject ( '403' , done , true ) ;
6925+ } ) ;
6926+ test ( 'get 403r' , function ( done ) {
6927+ getObject ( '403r' , done , true ) ;
6928+ } ) ;
6929+ test ( 'get 404' , function ( done ) {
6930+ getObject ( '404' , done , true ) ;
6931+ } ) ;
6932+ test ( 'get 404r' , function ( done ) {
6933+ getObject ( '404r' , done , true ) ;
6934+ } ) ;
6935+ test ( 'get 500' , function ( done ) {
6936+ getObject ( '500' , done ) ;
6937+ } ) ;
6938+ test ( 'get 500r' , function ( done ) {
6939+ getObject ( '500r' , done ) ;
6940+ } ) ;
6941+ test ( 'get 503' , function ( done ) {
6942+ getObject ( '503' , done ) ;
6943+ } ) ;
6944+ test ( 'get 503r' , function ( done ) {
6945+ getObject ( '503r' , done ) ;
6946+ } ) ;
6947+ test ( 'get 504' , function ( done ) {
6948+ getObject ( '504' , done ) ;
6949+ } ) ;
6950+ test ( 'get 504r' , function ( done ) {
6951+ getObject ( '504r' , done ) ;
6952+ } ) ;
6953+ test ( 'get shutdown' , function ( done ) {
6954+ getObject ( 'shutdown' , done ) ;
6955+ } ) ;
6956+ test ( 'get timeout' , function ( done ) {
6957+ getObject ( 'timeout' , done ) ;
6958+ } ) ;
6959+ } ) ;
6960+
6961+
67586962// 这条放最后执行
67596963group ( 'getStream() 流式下载 ECONNREFUSED 错误' , function ( ) {
67606964 test ( 'getStream() 流式下载 ECONNREFUSED 错误' , function ( done , assert ) {
0 commit comments