def get_headers(self, instant):
        """
        Build the list of headers needed in order to perform S3 operations.
        """
        headers = {'x-amz-date': _auth_v4.makeAMZDate(instant)}
        if self.body_producer is None:
            data = self.data
            if data is None:
                data = b""
            headers["x-amz-content-sha256"] = hashlib.sha256(data).hexdigest()
        else:
            data = None
            headers["x-amz-content-sha256"] = b"UNSIGNED-PAYLOAD"
        for key, value in self.metadata.iteritems():
            headers["x-amz-meta-" + key] = value
        for key, value in self.amz_headers.iteritems():
            headers["x-amz-" + key] = value

        # Before we check if the content type is set, let's see if we can set
        # it by guessing the the mimetype.
        self.set_content_type()
        if self.content_type is not None:
            headers["Content-Type"] = self.content_type
        if self.creds is not None:
            headers["Authorization"] = self.sign(
                headers,
                data,
                s3_url_context(self.endpoint, self.bucket, self.object_name),
                instant,
                method=self.action)
        return headers
def get_headers ( self , instant ) : headers = { 'x-amz-date' : _auth_v4 . makeAMZDate ( instant ) } if self . body_producer is None : data = self . data if data is None : data = b"" headers [ "x-amz-content-sha256" ] = hashlib . sha256 ( data ) . hexdigest ( ) else : data = None headers [ "x-amz-content-sha256" ] = b"UNSIGNED-PAYLOAD" for key , value in self . metadata . iteritems ( ) : headers [ "x-amz-meta-" + key ] = value for key , value in self . amz_headers . iteritems ( ) : headers [ "x-amz-" + key ] = value self . set_content_type ( ) if self . content_type is not None : headers [ "Content-Type" ] = self . content_type if self . creds is not None : headers [ "Authorization" ] = self . sign ( headers , data , s3_url_context ( self . endpoint , self . bucket , self . object_name ) , instant , method = self . action ) return headers
Build the list of headers needed in order to perform S3 operations.