def _bucket_response(self, request, full_url, headers):
    querystring = self._get_querystring(full_url)
    method = request.method
    region_name = parse_region_from_url(full_url)
    bucket_name = self.parse_bucket_name_from_url(request, full_url)
    if (not bucket_name):
        return self.all_buckets()
    self.data['BucketName'] = bucket_name
    if hasattr(request, 'body'):
        body = request.body
    else:
        body = request.data
    if (body is None):
        body = b''
    if isinstance(body, bytes):
        body = body.decode('utf-8')
    body = '{0}'.format(body).encode('utf-8')
    if (method == 'HEAD'):
        return self._bucket_response_head(bucket_name, querystring)
    elif (method == 'GET'):
        return self._bucket_response_get(bucket_name, querystring)
    elif (method == 'PUT'):
        return self._bucket_response_put(request, body, region_name, bucket_name, querystring)
    elif (method == 'DELETE'):
        return self._bucket_response_delete(body, bucket_name, querystring)
    elif (method == 'POST'):
        return self._bucket_response_post(request, body, bucket_name)
    else:
        raise NotImplementedError('Method {0} has not been implemented in the S3 backend yet'.format(method))
def _bucket_response(self, request, full_url, headers):
    querystring = self._get_querystring(full_url)
    method = request.method
    region_name = parse_region_from_url(full_url)
    bucket_name = self.parse_bucket_name_from_url(request, full_url)
    if (not bucket_name):
        return self.all_buckets()
    self.data['BucketName'] = bucket_name
    if hasattr(request, 'body'):
        body = request.body
    else:
        body = request.data
    if (body is None):
        body = b
    if isinstance(body, bytes):
        body = body.decode('utf-8')
    body = '{0}'.format(body).encode('utf-8')
    if (method == 'HEAD'):
        return self._bucket_response_head(bucket_name, querystring)
    elif (method == 'GET'):
        return self._bucket_response_get(bucket_name, querystring)
    elif (method == 'PUT'):
        return self._bucket_response_put(request, body, region_name, bucket_name, querystring)
    elif (method == 'DELETE'):
        return self._bucket_response_delete(body, bucket_name, querystring)
    elif (method == 'POST'):
        return self._bucket_response_post(request, body, bucket_name)
    else:
        raise NotImplementedError('Method {0} has not been implemented in the S3 backend yet'.format(method))