'HTTP PUT request handler.'

@public
@cors_validation
def PUT(self, req):

    error_response = (self.clean_acls(req) or check_metadata(req, 'container'))
    if error_response:
        return error_response
    policy_index = self._convert_policy_to_index(req)
    if (not req.environ.get('swift_owner')):
        for key in self.app.swift_owner_headers:
            req.headers.pop(key, None)
    if (len(self.container_name) > constraints.MAX_CONTAINER_NAME_LENGTH):
        resp = HTTPBadRequest(request=req)
        resp.body = ('Container    name    length    of    %d    longer    than    %d' % (len(self.container_name), constraints.MAX_CONTAINER_NAME_LENGTH))
        return resp
    (account_partition, accounts, container_count) = self.account_info(self.account_name, req)
    if ((not accounts) and self.app.account_autocreate):
        self.autocreate_account(req, self.account_name)
        (account_partition, accounts, container_count) = self.account_info(self.account_name, req)
    if (not accounts):
        return HTTPNotFound(request=req)
    if ((0 < self.app.max_containers_per_account <= container_count) and (self.account_name not in self.app.max_containers_whitelist)):
        container_info = self.container_info(self.account_name, self.container_name, req)
        if (not is_success(container_info.get('status'))):
            resp = HTTPForbidden(request=req)
            resp.body = ('Reached    container    limit    of    %s' % self.app.max_containers_per_account)
            return resp
    (container_partition, containers) = self.app.container_ring.get_nodes(self.account_name, self.container_name)
    headers = self._backend_requests(req, len(containers), account_partition, accounts, policy_index)
    clear_info_cache(self.app, req.environ, self.account_name, self.container_name)
    resp = self.make_requests(req, self.app.container_ring, container_partition, 'PUT', req.swift_entity_path, headers)
    return resp
