def put_container(self, account_name=None, container_name=None, headers=None, response_dict=None):
        """ HTTP PUT Container handler."""

        container_partition, containers = self.container_ring.get_nodes(account_name, container_name)

        statuses = []
        for i in range(self.upload_replica_num):
            container_url = 'http://%s:%d/%s/%d/%s/%s' % (containers[0]['ip'], containers[0]['port'],
                                                          containers[0]['device'], container_partition,
                                                          account_name, container_name)
            parsed = urlparse(container_url)
            path = parsed.path
            http_url = parsed.scheme + '://' + parsed.netloc
            conn = HTTPConnection(http_url)
            if headers:
                headers = dict(headers)
            else:
                headers = {}
            headers['X-Timestamp'] = normalize_timestamp(time.time())

            conn.request('PUT', path, '', headers)

            resp = conn.getresponse()
            body = resp.read()
            store_response(resp, response_dict)
            http_log(('%s%s' % (container_url.replace(parsed.path, ''), path), 'PUT',),
                     {'headers': headers}, resp, body)
            if resp.status < 200 or resp.status >= 300:
                raise ClientException.from_response(resp, 'Container PUT failed', body)
            statuses.append(resp.status)

        return statuses
    def put_object(self, account_name=None, container_name=None, object_name=None,
                   uploadfile_path=None, headers=None, response_dict=None):
        """HTTP PUT Object handler.
        First to fetch container info to update the header,
        or you will not find object info in container
        even you put a container by manual"""

        container_partition, containers = self.container_ring.get_nodes(account_name, container_name)
        container_info = {'X-Container-Host': str(containers[0]['ip']) + ':' + str(containers[0]['port']),
                          'X-Container-Device': containers[0]['device'],
                          'X-Container-Partition': container_partition}

        part, nodes = self.object_ring.get_nodes(account_name, container_name, object_name)

        # there may be incompatibility problem, or just use file read
        file_data = StringIO.StringIO()
        with open(uploadfile_path, 'r') as upload_file:
            file_data.write(upload_file.read())

        # not concurrent http_connect
        statuses = []
        for i in range(self.upload_replica_num):
            object_url = 'http://%s:%d/%s/%d/%s/%s/%s' % (nodes[i]['ip'], nodes[i]['port'],
                                                          nodes[i]['device'], part,
                                                          account_name, container_name, object_name)
            parsed = urlparse(object_url)
            path = parsed.path
            http_url = parsed.scheme + '://' + parsed.netloc
            conn = HTTPConnection(http_url)
            if headers:
                headers = dict(headers)
            else:
                headers = {}
            headers['x-timestamp'] = normalize_timestamp(time.time())
            headers['Content-Type'] = 'application/octet-stream'
            headers.update(container_info)

            conn.request('PUT', path, file_data.getvalue(), headers)

            resp = conn.getresponse()
            body = resp.read()
            http_log(('%s%s' % (object_url.replace(parsed.path, ''), path), 'PUT',),
                     {'headers': headers}, resp, body)
            store_response(resp, response_dict)
            if resp.status < 200 or resp.status >= 300:
                raise ClientException.from_response(resp, 'Object PUT failed', body)
            # etag = resp.getheader('etag', '').strip('"')
            statuses.append(resp.status)

        return statuses