src/base.js
function submitRequest(params, callback) {
    var self = this;

    // 处理 headers
    !params.headers && (params.headers = {});

    // 处理 query
    !params.qs && (params.qs = {});
    params.VersionId && (params.qs.versionId = params.VersionId);
    params.qs = util.clearKey(params.qs);

    // 清理 undefined 和 null 字段
    params.headers && (params.headers = util.clearKey(params.headers));
    params.qs && (params.qs = util.clearKey(params.qs));

    var Query = util.clone(params.qs);
    params.action && (Query[params.action] = '');

    var next = function (tryIndex) {
        var oldClockOffset = self.options.SystemClockOffset;
        getAuthorizationAsync.call(self, {
            Bucket: params.Bucket || '',
            Region: params.Region || '',
            Method: params.method,
            Key: params.Key,
            Query: Query,
            Headers: params.headers,
            Action: params.Action,
            ResourceKey: params.ResourceKey,
            Scope: params.Scope,
        }, function (err, AuthData) {
            params.AuthData = AuthData;
            _submitRequest.call(self, params, function (err, data) {
                if (err && tryIndex < 2 && (oldClockOffset !== self.options.SystemClockOffset || allowRetry.call(self, err))) {
                    if (params.headers) {
                        delete params.headers.Authorization;
                        delete params.headers['token'];
                        delete params.headers['clientIP'];
                        delete params.headers['clientUA'];
                        delete params.headers['x-cos-security-token'];
                    }
                    next(tryIndex + 1);
                } else {
                    callback(err, data);
                }
            });
        });
    };
    next(0);

}
function submitRequest(params, callback) {
    var self = this;

    // 处理 headers
    !params.headers && (params.headers = {});

    // 处理 query
    !params.qs && (params.qs = {});
    params.VersionId && (params.qs.versionId = params.VersionId);
    params.qs = util.clearKey(params.qs);

    // 清理 undefined 和 null 字段
    params.headers && (params.headers = util.clearKey(params.headers));
    params.qs && (params.qs = util.clearKey(params.qs));

    var Query = util.clone(params.qs);
    params.action && (Query[params.action] = '');

    var next = function (tryIndex) {
        var oldClockOffset = self.options.SystemClockOffset;
        getAuthorizationAsync.call(self, {
            Bucket: params.Bucket || '',
            Region: params.Region || '',
            Method: params.method,
            Key: params.Key,
            Query: Query,
            Headers: params.headers,
            Action: params.Action,
            ResourceKey: params.ResourceKey,
            Scope: params.Scope,
        }, function (err, AuthData) {
            params.AuthData = AuthData;
            _submitRequest.call(self, params, function (err, data) {
                if (err && tryIndex < 2 && (oldClockOffset !== self.options.SystemClockOffset || allowRetry.call(self, err))) {
                    if (params.headers) {
                        delete params.headers.Authorization;
                        delete params.headers['token'];
                        delete params.headers['clientIP'];
                        delete params.headers['clientUA'];
                        delete params.headers['x-cos-security-token'];
                    }
                    next(tryIndex + 1);
                } else {
                    callback(err, data);
                }
            });
        });
    };
    next(0);

}
function submitRequest ( params , callback ) { var self = this ; // 处理 headers ! params . headers && ( params . headers = { } ) ; // 处理 query ! params . qs && ( params . qs = { } ) ; params . VersionId && ( params . qs . versionId = params . VersionId ) ; params . qs = util . clearKey ( params . qs ) ; // 清理 undefined 和 null 字段 params . headers && ( params . headers = util . clearKey ( params . headers ) ) ; params . qs && ( params . qs = util . clearKey ( params . qs ) ) ; var Query = util . clone ( params . qs ) ; params . action && ( Query [ params . action ] = '' ) ; var next = function ( tryIndex ) { var oldClockOffset = self . options . SystemClockOffset ; getAuthorizationAsync . call ( self , { Bucket : params . Bucket || '' , Region : params . Region || '' , Method : params . method , Key : params . Key , Query : Query , Headers : params . headers , Action : params . Action , ResourceKey : params . ResourceKey , Scope : params . Scope , } , function ( err , AuthData ) { params . AuthData = AuthData ; _submitRequest . call ( self , params , function ( err , data ) { if ( err && tryIndex < 2 && ( oldClockOffset !== self . options . SystemClockOffset || allowRetry . call ( self , err ) ) ) { if ( params . headers ) { delete params . headers . Authorization ; delete params . headers [ 'token' ] ; delete params . headers [ 'clientIP' ] ; delete params . headers [ 'clientUA' ] ; delete params . headers [ 'x-cos-security-token' ] ; } next ( tryIndex + 1 ) ; } else { callback ( err , data ) ; } } ) ; } ) ; } ; next ( 0 ) ; }
获取签名并发起请求
获取签名并发起请求