Change s3 urls to ordereddict to fix python3 issues.
This commit is contained in:
parent
fe090d7bb5
commit
075d008509
@ -40,11 +40,13 @@ class ResponseObject(_TemplateEnvironmentMixin):
|
||||
return template.render(buckets=all_buckets)
|
||||
|
||||
def subdomain_based_buckets(self, request):
|
||||
host = request.headers['host']
|
||||
host = request.headers.get('host', request.headers.get('Host'))
|
||||
if host.startswith("localhost"):
|
||||
# For localhost, default to path-based buckets
|
||||
return False
|
||||
return host != 's3.amazonaws.com' and not re.match("s3.(.*).amazonaws.com", host)
|
||||
|
||||
path_based = (host == 's3.amazonaws.com' or re.match("s3.(.*).amazonaws.com", host))
|
||||
return not path_based
|
||||
|
||||
def is_delete_keys(self, request, path, bucket_name):
|
||||
if self.subdomain_based_buckets(request):
|
||||
|
@ -1,4 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from moto.compat import OrderedDict
|
||||
from .responses import S3ResponseInstance
|
||||
|
||||
url_bases = [
|
||||
@ -6,13 +8,13 @@ url_bases = [
|
||||
"https?://(?P<bucket_name>[a-zA-Z0-9\-_.]*)\.?s3(.*).amazonaws.com"
|
||||
]
|
||||
|
||||
url_paths = {
|
||||
url_paths = OrderedDict([
|
||||
# subdomain bucket
|
||||
'{0}/$': S3ResponseInstance.bucket_response,
|
||||
('{0}/$', S3ResponseInstance.bucket_response),
|
||||
|
||||
# subdomain key of path-based bucket
|
||||
'{0}/(?P<key_or_bucket_name>.+)': S3ResponseInstance.ambiguous_response,
|
||||
('{0}/(?P<key_or_bucket_name>.+)', S3ResponseInstance.ambiguous_response),
|
||||
|
||||
# path-based bucket + key
|
||||
'{0}/(?P<bucket_name_path>[a-zA-Z0-9\-_./]+)/(?P<key_name>.+)': S3ResponseInstance.key_response,
|
||||
}
|
||||
('{0}/(?P<bucket_name_path>[a-zA-Z0-9\-_./]+)/(?P<key_name>.+)', S3ResponseInstance.key_response),
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user