1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

another attempt at s3 region redirecting

This commit is contained in:
geemus 2015-01-09 16:42:07 -06:00
parent 3dad29880c
commit f8513dc928

View file

@ -550,12 +550,15 @@ module Fog
new_params[:host] = URI.parse(headers['Location']).host
else
body = error.response.is_a?(Hash) ? error.response[:body] : error.response.body
# some errors provide info indirectly
new_params[:bucket_name] = %r{<Bucket>([^<]*)</Bucket>}.match(body).captures.first
new_params[:host] = %r{<Endpoint>([^<]*)</Endpoint>}.match(body).captures.first
# some errors provide it directly
@new_region = %r{<Region>([^<]*)</Region>}.match(body).captures.first
end
Fog::Logger.warning("fog: followed redirect to #{host}, connecting to the matching region will be more performant")
original_region, original_signer = @region, @signer
@region = case new_params[:host]
@region = @new_region || case new_params[:host]
when 's3.amazonaws.com', 's3-external-1.amazonaws.com'
DEFAULT_REGION
else