Skip to content

Commit

Permalink
Hoist region check to fix_s3_host
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleknap committed Oct 12, 2015
1 parent fb2db80 commit 4c04307
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions botocore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,16 +635,18 @@ def fix_s3_host(request, signature_version, region_name, **kwargs):
# signed with signature version 4.
if signature_version in ['s3v4', 'v4']:
return
elif not _allowed_region(region_name):
return
try:
switch_to_virtual_host_style(
request, signature_version, region_name, 's3.amazonaws.com')
request, signature_version, 's3.amazonaws.com')
except InvalidDNSNameError as e:
bucket_name = e.kwargs['bucket_name']
logger.debug('Not changing URI, bucket is not DNS compatible: %s',
bucket_name)


def switch_to_virtual_host_style(request, signature_version, region_name,
def switch_to_virtual_host_style(request, signature_version,
default_endpoint_url=None, **kwargs):
"""
This is a handler to force virtual host style s3 addressing no matter
Expand All @@ -653,7 +655,6 @@ def switch_to_virtual_host_style(request, signature_version, region_name,
:param request: A AWSRequest object that is about to be sent.
:param signature_version: The signature version to sign with
:param region_name: The name of the region to sign with
:param default_endpoint_url: The endpoint to use when switching to a
virtual style. If None is supplied, the virtual host will be
constructed from the url of the request.
Expand Down Expand Up @@ -686,7 +687,7 @@ def switch_to_virtual_host_style(request, signature_version, region_name,
return
logger.debug('Checking for DNS compatible bucket for: %s',
request.url)
if check_dns_name(bucket_name) and _allowed_region(region_name):
if check_dns_name(bucket_name):
# If the operation is on a bucket, the auth_path must be
# terminated with a '/' character.
if len(path_parts) == 2:
Expand Down

0 comments on commit 4c04307

Please sign in to comment.