def __call__(self, request):
        """Sign the request."""
        hashed_body = digester(request.body or '')
        stripped_path = request.path_url.partition('?')[0]
        hashed_path = digester(stripped_path)
        timestamp = datetime.datetime.utcnow().strftime(self.datetime_fmt)

        canonical_request = self.canonical_request(
            request.method, hashed_path, hashed_body, timestamp)

        signed = self.private_key.sign(canonical_request, b64=True)
        signed_chunks = splitter(signed, chunksize=60)
        signed_headers = {
            'X-Ops-Authorization-%d' % (i+1): segment
            for i, segment in enumerate(signed_chunks)
        }

        auth_headers = {
            'X-Ops-Sign': 'algorithm=sha1;version=1.0',
            'X-Ops-UserId': self.user_id,
            'X-Ops-Timestamp': timestamp,
            'X-Ops-Content-Hash': hashed_body,
        }

        auth_headers.update(signed_headers)
        request.headers.update(auth_headers)

        return request
def __call__ ( self , request ) : hashed_body = digester ( request . body or '' ) stripped_path = request . path_url . partition ( '?' ) [ 0 ] hashed_path = digester ( stripped_path ) timestamp = datetime . datetime . utcnow ( ) . strftime ( self . datetime_fmt ) canonical_request = self . canonical_request ( request . method , hashed_path , hashed_body , timestamp ) signed = self . private_key . sign ( canonical_request , b64 = True ) signed_chunks = splitter ( signed , chunksize = 60 ) signed_headers = { 'X-Ops-Authorization-%d' % ( i + 1 ) : segment for i , segment in enumerate ( signed_chunks ) } auth_headers = { 'X-Ops-Sign' : 'algorithm=sha1;version=1.0' , 'X-Ops-UserId' : self . user_id , 'X-Ops-Timestamp' : timestamp , 'X-Ops-Content-Hash' : hashed_body , } auth_headers . update ( signed_headers ) request . headers . update ( auth_headers ) return request
Sign the request.