(self, flow)
return hashlib.sha256(repr(key)).digest()
Calculates a loose hash of the flow request.
Calculates a loose hash of the flow request.
Calculates a loose hash of the flow request .
def _hash(self, flow):
        """
            Calculates a loose hash of the flow request.
        """
        r = flow.request
        key = [
            str(r.host),
            str(r.port),
            str(r.scheme),
            str(r.method),
            str(r.path),
            str(r.content),
        ]
        if self.headers:
            hdrs = []
            for i in self.headers:
                v = r.headers[i]
                # Slightly subtle: we need to convert everything to strings
                # to prevent a mismatch between unicode/non-unicode.
                v = [str(x) for x in v]
                hdrs.append((i, v))
            key.append(repr(hdrs))
        return hashlib.sha256(repr(key)).digest()
def _hash ( self , flow ) : r = flow . request key = [ str ( r . host ) , str ( r . port ) , str ( r . scheme ) , str ( r . method ) , str ( r . path ) , str ( r . content ) , ] if self . headers : hdrs = [ ] for i in self . headers : v = r . headers [ i ] # Slightly subtle: we need to convert everything to strings # to prevent a mismatch between unicode/non-unicode. v = [ str ( x ) for x in v ] hdrs . append ( ( i , v ) ) key . append ( repr ( hdrs ) ) return hashlib . sha256 ( repr ( key ) ) . digest ( )