lib/services/s3.js
function requestBucketRegion(resp, done) {
    var error = resp.error;
    var req = resp.request;
    var bucket = req.params.Bucket || null;

    if (!error || !bucket || error.region || req.operation === 'listObjects' ||
        (AWS.util.isNode() && req.operation === 'headBucket') ||
        (error.statusCode === 400 && req.operation !== 'headObject') ||
        regionRedirectErrorCodes.indexOf(error.code) === -1) {
      return done();
    }
    var reqOperation = AWS.util.isNode() ? 'headBucket' : 'listObjects';
    var reqParams = {Bucket: bucket};
    if (reqOperation === 'listObjects') reqParams.MaxKeys = 0;
    var regionReq = req.service[reqOperation](reqParams);
    regionReq._requestRegionForBucket = bucket;
    regionReq.send(function() {
      var region = req.service.bucketRegionCache[bucket] || null;
      error.region = region;
      done();
    });
  }
function requestBucketRegion(resp, done) {
    var error = resp.error;
    var req = resp.request;
    var bucket = req.params.Bucket || null;

    if (!error || !bucket || error.region || req.operation === 'listObjects' ||
        (AWS.util.isNode() && req.operation === 'headBucket') ||
        (error.statusCode === 400 && req.operation !== 'headObject') ||
        regionRedirectErrorCodes.indexOf(error.code) === -1) {
      return done();
    }
    var reqOperation = AWS.util.isNode() ? 'headBucket' : 'listObjects';
    var reqParams = {Bucket: bucket};
    if (reqOperation === 'listObjects') reqParams.MaxKeys = 0;
    var regionReq = req.service[reqOperation](reqParams);
    regionReq._requestRegionForBucket = bucket;
    regionReq.send(function() {
      var region = req.service.bucketRegionCache[bucket] || null;
      error.region = region;
      done();
    });
  }
function requestBucketRegion ( resp , done ) { var error = resp . error ; var req = resp . request ; var bucket = req . params . Bucket || null ; if ( ! error || ! bucket || error . region || req . operation === 'listObjects' || ( AWS . util . isNode ( ) && req . operation === 'headBucket' ) || ( error . statusCode === 400 && req . operation !== 'headObject' ) || regionRedirectErrorCodes . indexOf ( error . code ) === - 1 ) { return done ( ) ; } var reqOperation = AWS . util . isNode ( ) ? 'headBucket' : 'listObjects' ; var reqParams = { Bucket : bucket } ; if ( reqOperation === 'listObjects' ) reqParams . MaxKeys = 0 ; var regionReq = req . service [ reqOperation ] ( reqParams ) ; regionReq . _requestRegionForBucket = bucket ; regionReq . send ( function ( ) { var region = req . service . bucketRegionCache [ bucket ] || null ; error . region = region ; done ( ) ; } ) ; }
If region was not obtained synchronously, then send async request
to get bucket region for errors resulting from wrong region.

@api private
If region was not obtained synchronously then send async request to get bucket region for errors resulting from wrong region .