MCPcopy Create free account
hub / github.com/secdev/scapy / HuffmanNode

Class HuffmanNode

scapy/contrib/http2.py:686–722  ·  view source on GitHub ↗

HuffmanNode is an entry of the binary tree used for encoding/decoding HPack compressed HTTP/2 headers

Source from the content-addressed store, hash-verified

684
685
686class HuffmanNode(object):
687 """ HuffmanNode is an entry of the binary tree used for encoding/decoding
688 HPack compressed HTTP/2 headers
689 """
690
691 __slots__ = ['left', 'right']
692 """@var l: the left branch of this node
693 @var r: the right branch of this Node
694
695 These variables can value None (leaf node), another HuffmanNode, or a
696 symbol. Symbols are either a character or the End Of String symbol (class
697 EOS)
698 """
699
700 def __init__(self, left, right):
701 # type: (Union[None, HuffmanNode, EOS, str], Union[None, HuffmanNode, EOS, str]) -> None # noqa: E501
702 self.left = left
703 self.right = right
704
705 def __getitem__(self, b):
706 # type: (int) -> Union[None, HuffmanNode, EOS, str]
707 return self.right if b else self.left
708
709 def __setitem__(self, b, val):
710 # type: (int, Union[None, HuffmanNode, EOS, str]) -> None
711 if b:
712 self.right = val
713 else:
714 self.left = val
715
716 def __str__(self):
717 # type: () -> str
718 return self.__repr__()
719
720 def __repr__(self):
721 # type: () -> str
722 return '({}, {})'.format(self.left, self.right)
723
724
725class InvalidEncodingException(Exception):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…