def extract_client(self, request):
        """Extract the id and output from the provided MalleableRequest.

        Args:
            request (MalleableRequest)

        Returns:
            tuple: id, output
        """
        for u in (self.client.uris if self.client.uris else ["/"]):
            if u.lower() in request.path.lower():
                id = request.extract(self.client, self.client.id.terminator)
                if isinstance(id, str):
                    id = id.encode('latin-1')
                output = request.extract(self.client,
                                         self.client.output.terminator)
                trans_r = self.client.id.transform_r(id) if id else None
                if isinstance(trans_r, str):
                    trans_r = trans_r.encode("latin-1")
                return (trans_r, self.client.output.transform_r(output)
                        if output else None)
        return (None, None)
Exemplo n.º 2
0
    def extract_client(self, request):
        """Extract the metadata from the provided MalleableRequest.

        Args:
            request (MalleableRequest)

        Returns: None
        """
        for u in (self.client.uris if self.client.uris else ["/"]):
            if u.lower() in request.path.lower():
                metadata = request.extract(self.client, self.client.metadata.terminator)
                if metadata:
                    return self.client.metadata.transform_r(metadata)
        return None
Exemplo n.º 3
0
    def extract_client(self, request):
        """Extract the metadata from the provided MalleableRequest.

        Args:
            request (MalleableRequest)

        Returns:
            str: metadata
        """
        for u in (self.client.uris if self.client.uris else ["/"]):
            if u.lower() in request.path.lower():
                metadata = request.extract(self.client, self.client.metadata.terminator)
                if metadata:
                    m = self.client.metadata.transform_r(metadata)
                    if isinstance(m, str):
                        m = m.encode("latin-1")
                    return m
        return None