88import logging
99
1010from .table import HeaderTable , table_entry_size
11- from .compat import to_byte , to_bytes
1211from .exceptions import (
1312 HPACKDecodingError , OversizedHeaderListError , InvalidTableSizeError
1413)
@@ -46,8 +45,8 @@ def _unicode_if_needed(header, raw):
4645 Provides a header as a unicode string if raw is False, otherwise returns
4746 it as a bytestring.
4847 """
49- name = to_bytes (header [0 ])
50- value = to_bytes (header [1 ])
48+ name = bytes (header [0 ])
49+ value = bytes (header [1 ])
5150 if not raw :
5251 name = name .decode ('utf-8' )
5352 value = value .decode ('utf-8' )
@@ -106,10 +105,10 @@ def decode_integer(data, prefix_bits):
106105 mask = (0xFF >> (8 - prefix_bits ))
107106
108107 try :
109- number = to_byte ( data [0 ]) & mask
108+ number = data [0 ] & mask
110109 if number == max_number :
111110 while True :
112- next_byte = to_byte ( data [index ])
111+ next_byte = data [index ]
113112 index += 1
114113
115114 if next_byte >= 128 :
@@ -457,7 +456,7 @@ def decode(self, data, raw=False):
457456 while current_index < data_len :
458457 # Work out what kind of header we're decoding.
459458 # If the high bit is 1, it's an indexed field.
460- current = to_byte ( data [current_index ])
459+ current = data [current_index ]
461460 indexed = True if current & 0x80 else False
462461
463462 # Otherwise, if the second-highest bit is 1 it's a field that does
@@ -565,11 +564,11 @@ def _decode_literal(self, data, should_index):
565564 # When should_index is false, if the low four bits of the first byte
566565 # are nonzero the header name is indexed.
567566 if should_index :
568- indexed_name = to_byte ( data [0 ]) & 0x3F
567+ indexed_name = data [0 ] & 0x3F
569568 name_len = 6
570569 not_indexable = False
571570 else :
572- high_byte = to_byte ( data [0 ])
571+ high_byte = data [0 ]
573572 indexed_name = high_byte & 0x0F
574573 name_len = 4
575574 not_indexable = high_byte & 0x10
@@ -591,7 +590,7 @@ def _decode_literal(self, data, should_index):
591590 if len (name ) != length :
592591 raise HPACKDecodingError ("Truncated header block" )
593592
594- if to_byte ( data [0 ]) & 0x80 :
593+ if data [0 ] & 0x80 :
595594 name = decode_huffman (name )
596595 total_consumed = consumed + length + 1 # Since we moved forward 1.
597596
@@ -603,7 +602,7 @@ def _decode_literal(self, data, should_index):
603602 if len (value ) != length :
604603 raise HPACKDecodingError ("Truncated header block" )
605604
606- if to_byte ( data [0 ]) & 0x80 :
605+ if data [0 ] & 0x80 :
607606 value = decode_huffman (value )
608607
609608 # Updated the total consumed length.
0 commit comments