@@ -628,9 +628,9 @@ def test_request_examples_without_huffman(self):
628628 (':path' , '/' ,),
629629 (':authority' , 'www.example.com' ),
630630 ]
631- # The first_header_table doesn't contain 'authority'
632- first_header_table = first_header_set [:: - 1 ][ 1 : ]
633- first_result = b'\x82 \x87 \ x86\x04 \x0f www.example.com'
631+ # The first_header_table doesn't contain anything.
632+ first_header_table = [ ]
633+ first_result = b'\x82 \x86 \x84 \x01 \x0f www.example.com'
634634
635635 assert e .encode (first_header_set , huffman = False ) == first_result
636636 assert list (e .header_table ) == [
@@ -645,13 +645,11 @@ def test_request_examples_without_huffman(self):
645645 ('cache-control' , 'no-cache' ),
646646 ]
647647 second_result = (
648- b'\x83 \ x82\x81 \x04 \ x0f www.example.com\x0f \x0c \x08 no-cache'
648+ b'\x82 \x86 \x84 \x01 \ x0f www.example.com\x0f \t \x08 no-cache'
649649 )
650650
651651 assert e .encode (second_header_set , huffman = False ) == second_result
652- assert list (e .header_table ) == [
653- (n .encode ('utf-8' ), v .encode ('utf-8' )) for n , v in first_header_table
654- ]
652+ assert list (e .header_table ) == []
655653
656654 third_header_set = [
657655 (':method' , 'GET' ,),
@@ -661,13 +659,13 @@ def test_request_examples_without_huffman(self):
661659 ('custom-key' , 'custom-value' ),
662660 ]
663661 third_result = (
664- b'\x83 \x8a \x89 \x06 \x0f www.example.com@\n custom-key\x0c custom-value'
662+ b'\x82 \x87 \x85 \x01 \x0f www.example.com@\n custom-key\x0c custom-value'
665663 )
666664
667665 assert e .encode (third_header_set , huffman = False ) == third_result
668666 # Don't check the header table here, it's just too complex to be
669667 # reliable. Check its length though.
670- assert len (e .header_table ) == 6
668+ assert len (e .header_table ) == 1
671669
672670 def test_request_examples_with_huffman (self ):
673671 """
@@ -681,16 +679,12 @@ def test_request_examples_with_huffman(self):
681679 (':path' , '/' ,),
682680 (':authority' , 'www.example.com' ),
683681 ]
684- # The first_header_table doesn't contain 'authority'
685- first_header_table = first_header_set [::- 1 ][1 :]
686682 first_result = (
687- b'\x82 \x87 \ x86\x04 \x8c \xf1 \xe3 \xc2 \xe5 \xf2 :k\xa0 \xab \x90 \xf4 \xff '
683+ b'\x82 \x86 \x84 \x01 \x8c \xf1 \xe3 \xc2 \xe5 \xf2 :k\xa0 \xab \x90 \xf4 \xff '
688684 )
689685
690686 assert e .encode (first_header_set , huffman = True ) == first_result
691- assert list (e .header_table ) == [
692- (n .encode ('utf-8' ), v .encode ('utf-8' )) for n , v in first_header_table
693- ]
687+ assert list (e .header_table ) == []
694688
695689 second_header_set = [
696690 (':method' , 'GET' ,),
@@ -700,18 +694,13 @@ def test_request_examples_with_huffman(self):
700694 ('cache-control' , 'no-cache' ),
701695 ]
702696 second_result = (
703- b'\x83 \ x82\x81 \x04 \x8c \xf1 \xe3 \xc2 \xe5 \xf2 :k\xa0 \xab \x90 \xf4 \xff '
704- b'\x0f \x0c \x86 \xa8 \xeb \x10 d\x9c \xbf '
697+ b'\x82 \x86 \x84 \x01 \x8c \xf1 \xe3 \xc2 \xe5 \xf2 :k\xa0 \xab \x90 \xf4 \xff '
698+ b'\x0f \t \x86 \xa8 \xeb \x10 d\x9c \xbf '
705699 )
706700
707701 assert e .encode (second_header_set , huffman = True ) == second_result
708- assert list (e .header_table ) == [
709- (n .encode ('utf-8' ), v .encode ('utf-8' )) for n , v in first_header_table
710- ]
702+ assert list (e .header_table ) == []
711703
712- # This request has not enough headers in common with the previous
713- # request to take advantage of the differential encoding. Therefore,
714- # the reference set is emptied before encoding the header fields.
715704 third_header_set = [
716705 (':method' , 'GET' ,),
717706 (':scheme' , 'https' ,),
@@ -720,14 +709,12 @@ def test_request_examples_with_huffman(self):
720709 ('custom-key' , 'custom-value' ),
721710 ]
722711 third_result = (
723- b'\x83 \x8a \x89 \x06 \x8c \xf1 \xe3 \xc2 \xe5 \xf2 :k\xa0 \xab \x90 \xf4 \xff @'
712+ b'\x82 \x87 \x85 \x01 \x8c \xf1 \xe3 \xc2 \xe5 \xf2 :k\xa0 \xab \x90 \xf4 \xff @'
724713 b'\x88 %\xa8 I\xe9 [\xa9 }\x7f \x89 %\xa8 I\xe9 [\xb8 \xe8 \xb4 \xbf '
725714 )
726715
727716 assert e .encode (third_header_set , huffman = True ) == third_result
728- # Don't check the header table here, it's just too complex to be
729- # reliable. Check its length though.
730- assert len (e .header_table ) == 6
717+ assert len (e .header_table ) == 1
731718
732719 # These tests are custom, for hyper.
733720 def test_resizing_header_table (self ):
@@ -830,13 +817,10 @@ def test_request_examples_without_huffman(self):
830817 (':authority' , 'www.example.com' ),
831818 ]
832819 # The first_header_table doesn't contain 'authority'
833- first_header_table = first_header_set [::- 1 ][1 :]
834- first_data = b'\x82 \x87 \x86 \x04 \x0f www.example.com'
820+ first_data = b'\x82 \x86 \x84 \x01 \x0f www.example.com'
835821
836- assert sorted (d .decode (first_data )) == sorted (first_header_set )
837- assert list (d .header_table ) == [
838- (n .encode ('utf-8' ), v .encode ('utf-8' )) for n , v in first_header_table
839- ]
822+ assert d .decode (first_data ) == first_header_set
823+ assert list (d .header_table ) == []
840824
841825 # This request takes advantage of the differential encoding of header
842826 # sets.
@@ -848,17 +832,12 @@ def test_request_examples_without_huffman(self):
848832 ('cache-control' , 'no-cache' ),
849833 ]
850834 second_data = (
851- b'\x83 \ x82\x81 \x04 \ x0f www.example.com\x0f \x0c \x08 no-cache'
835+ b'\x82 \x86 \x84 \x01 \ x0f www.example.com\x0f \t \x08 no-cache'
852836 )
853837
854- assert sorted (d .decode (second_data )) == sorted (second_header_set )
855- assert list (d .header_table ) == [
856- (n .encode ('utf-8' ), v .encode ('utf-8' )) for n , v in first_header_table
857- ]
838+ assert d .decode (second_data ) == second_header_set
839+ assert list (d .header_table ) == []
858840
859- # This request has not enough headers in common with the previous
860- # request to take advantage of the differential encoding. Therefore,
861- # the reference set is emptied before encoding the header fields.
862841 third_header_set = [
863842 (':method' , 'GET' ,),
864843 (':scheme' , 'https' ,),
@@ -867,13 +846,13 @@ def test_request_examples_without_huffman(self):
867846 ('custom-key' , 'custom-value' ),
868847 ]
869848 third_data = (
870- b'\x83 \x8a \x89 \x06 \x0f www.example.com@\n custom-key\x0c custom-value'
849+ b'\x82 \x87 \x85 \x01 \x0f www.example.com@\n custom-key\x0c custom-value'
871850 )
872851
873- assert sorted ( d .decode (third_data )) == sorted ( third_header_set )
852+ assert d .decode (third_data ) == third_header_set
874853 # Don't check the header table here, it's just too complex to be
875854 # reliable. Check its length though.
876- assert len (d .header_table ) == 6
855+ assert len (d .header_table ) == 1
877856
878857 def test_request_examples_with_huffman (self ):
879858 """
@@ -890,14 +869,11 @@ def test_request_examples_with_huffman(self):
890869 ]
891870 first_header_table = first_header_set [::- 1 ]
892871 first_data = (
893- b'\x82 \x87 \ x86\x04 \x8c \xf1 \xe3 \xc2 \xe5 \xf2 :k\xa0 \xab \x90 \xf4 \xff '
872+ b'\x82 \x86 \x84 \x01 \x8c \xf1 \xe3 \xc2 \xe5 \xf2 :k\xa0 \xab \x90 \xf4 \xff '
894873 )
895874
896- assert sorted (d .decode (first_data )) == sorted (first_header_set )
897- assert list (d .header_table ) == [
898- (n .encode ('utf-8' ), v .encode ('utf-8' )) for n , v in first_header_table
899- if n != ':authority'
900- ]
875+ assert d .decode (first_data ) == first_header_set
876+ assert list (d .header_table ) == []
901877
902878 second_header_set = [
903879 (':method' , 'GET' ,),
@@ -906,21 +882,14 @@ def test_request_examples_with_huffman(self):
906882 (':authority' , 'www.example.com' ,),
907883 ('cache-control' , 'no-cache' ),
908884 ]
909- second_header_table = second_header_set [::- 1 ]
910885 second_data = (
911- b'\x83 \ x82\x81 \x04 \x8c \xf1 \xe3 \xc2 \xe5 \xf2 :k\xa0 \xab \x90 \xf4 \xff '
912- b'\x0f \x0c \x86 \xa8 \xeb \x10 d\x9c \xbf '
886+ b'\x82 \x86 \x84 \x01 \x8c \xf1 \xe3 \xc2 \xe5 \xf2 :k\xa0 \xab \x90 \xf4 \xff '
887+ b'\x0f \t \x86 \xa8 \xeb \x10 d\x9c \xbf '
913888 )
914889
915- assert sorted (d .decode (second_data )) == sorted (second_header_set )
916- assert list (d .header_table ) == [
917- (n .encode ('utf-8' ), v .encode ('utf-8' )) for n , v in second_header_table
918- if n not in (':authority' , 'cache-control' )
919- ]
890+ assert d .decode (second_data ) == second_header_set
891+ assert list (d .header_table ) == []
920892
921- # This request has not enough headers in common with the previous
922- # request to take advantage of the differential encoding. Therefore,
923- # the reference set is emptied before encoding the header fields.
924893 third_header_set = [
925894 (':method' , 'GET' ,),
926895 (':scheme' , 'https' ,),
@@ -929,14 +898,12 @@ def test_request_examples_with_huffman(self):
929898 ('custom-key' , 'custom-value' ),
930899 ]
931900 third_data = (
932- b'\x83 \x8a \x89 \x06 \x8c \xf1 \xe3 \xc2 \xe5 \xf2 :k\xa0 \xab \x90 \xf4 \xff @'
901+ b'\x82 \x87 \x85 \x01 \x8c \xf1 \xe3 \xc2 \xe5 \xf2 :k\xa0 \xab \x90 \xf4 \xff @'
933902 b'\x88 %\xa8 I\xe9 [\xa9 }\x7f \x89 %\xa8 I\xe9 [\xb8 \xe8 \xb4 \xbf '
934903 )
935904
936- assert sorted (d .decode (third_data )) == sorted (third_header_set )
937- # Don't check the header table here, it's just too complex to be
938- # reliable. Check its length though.
939- assert len (d .header_table ) == 6
905+ assert d .decode (third_data ) == third_header_set
906+ assert len (d .header_table ) == 1
940907
941908 # These tests are custom, for hyper.
942909 def test_resizing_header_table (self ):
0 commit comments