Skip to content

Commit

Permalink
Fix bucket versioning when running under moto_server
Browse files Browse the repository at this point in the history
  • Loading branch information
John Lynn committed Feb 22, 2015
1 parent 19d12d3 commit 0496d46
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion moto/s3/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,14 @@ def _bucket_response_get(self, bucket_name, querystring, headers):
)

def _bucket_response_put(self, request, region_name, bucket_name, querystring, headers):
if hasattr(request, 'body'):
# Boto
body = request.body
else:
# Flask server
body = request.data
if 'versioning' in querystring:
ver = re.search('<Status>([A-Za-z]+)</Status>', request.body.decode('utf-8'))
ver = re.search('<Status>([A-Za-z]+)</Status>', body.decode('utf-8'))
if ver:
self.backend.set_bucket_versioning(bucket_name, ver.group(1))
template = self.response_template(S3_BUCKET_VERSIONING)
Expand Down

0 comments on commit 0496d46

Please sign in to comment.