@@ -76,7 +76,7 @@ def encode_integer(integer: int, prefix_bits: int) -> bytearray:
7676 return bytearray (elements )
7777
7878
79- def decode_integer (data : bytes , prefix_bits : int ) -> tuple [int , int ]:
79+ def decode_integer (data : bytes | memoryview , prefix_bits : int ) -> tuple [int , int ]:
8080 """
8181 Decodes an integer according to the wacky integer encoding rules
8282 defined in the HPACK spec. Returns a tuple of the decoded integer and the
@@ -548,7 +548,7 @@ def _assert_valid_table_size(self) -> None:
548548 msg = "Encoder did not shrink table size to within the max"
549549 raise InvalidTableSizeError (msg )
550550
551- def _update_encoding_context (self , data : bytes ) -> int :
551+ def _update_encoding_context (self , data : bytes | memoryview ) -> int :
552552 """
553553 Handles a byte that updates the encoding context.
554554 """
@@ -560,7 +560,7 @@ def _update_encoding_context(self, data: bytes) -> int:
560560 self .header_table_size = new_size
561561 return consumed
562562
563- def _decode_indexed (self , data : bytes ) -> tuple [HeaderTuple , int ]:
563+ def _decode_indexed (self , data : bytes | memoryview ) -> tuple [HeaderTuple , int ]:
564564 """
565565 Decodes a header represented using the indexed representation.
566566 """
@@ -569,16 +569,19 @@ def _decode_indexed(self, data: bytes) -> tuple[HeaderTuple, int]:
569569 log .debug ("Decoded %s, consumed %d" , header , consumed )
570570 return header , consumed
571571
572- def _decode_literal_no_index (self , data : bytes ) -> tuple [HeaderTuple , int ]:
572+ def _decode_literal_no_index (self , data : bytes | memoryview ) -> tuple [HeaderTuple , int ]:
573573 return self ._decode_literal (data , should_index = False )
574574
575- def _decode_literal_index (self , data : bytes ) -> tuple [HeaderTuple , int ]:
575+ def _decode_literal_index (self , data : bytes | memoryview ) -> tuple [HeaderTuple , int ]:
576576 return self ._decode_literal (data , should_index = True )
577577
578- def _decode_literal (self , data : bytes , should_index : bool ) -> tuple [HeaderTuple , int ]:
578+ def _decode_literal (self , data : bytes | memoryview , should_index : bool ) -> tuple [HeaderTuple , int ]:
579579 """
580580 Decodes a header represented with a literal.
581581 """
582+ if isinstance (data , memoryview ):
583+ data = data .tobytes () # pragma: no cover
584+
582585 total_consumed = 0
583586
584587 # When should_index is true, if the low six bits of the first byte are
0 commit comments