def test_resizing_header_table_sends_multiple_updates(self): e = Encoder() e.header_table_size = 40 e.header_table_size = 100 e.header_table_size = 40 header_set = [(':method', 'GET')] out = e.encode(header_set, huffman=True) assert out == b'\x3F\x09\x3F\x45\x3F\x09\x82'
def test_resizing_header_table_to_same_size_ignored(self): e = Encoder() # These size changes should be ignored e.header_table_size = 4096 e.header_table_size = 4096 e.header_table_size = 4096 # These size changes should be encoded e.header_table_size = 40 e.header_table_size = 100 e.header_table_size = 40 header_set = [(':method', 'GET')] out = e.encode(header_set, huffman=True) assert out == b'\x3F\x09\x3F\x45\x3F\x09\x82'
def test_resizing_header_table(self): # We need to encode a substantial number of headers, to populate the # header table. e = Encoder() header_set = [ (':method', 'GET'), (':scheme', 'https'), (':path', '/some/path'), (':authority', 'www.example.com'), ('custom-key', 'custom-value'), ( "user-agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) " "Gecko/20100101 Firefox/16.0", ), ( "accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;" "q=0.8", ), ('X-Lukasa-Test', '88989'), ] e.encode(header_set, huffman=True) # Resize the header table to a size so small that nothing can be in it. e.header_table_size = 40 assert len(e.header_table.dynamic_entries) == 0
def test_evicting_header_table_objects(self): e = Encoder() # Set the header table size large enough to include one header. e.header_table_size = 66 header_set = [('a', 'b'), ('long-custom-header', 'longish value')] e.encode(header_set) assert len(e.header_table.dynamic_entries) == 1
def test_indexed_header_field_from_static_table(self): e = Encoder() e.header_table_size = 0 header_set = {':method': 'GET'} result = b'\x82' # Make sure we don't emit an encoding context update. e.header_table.resized = False assert e.encode(header_set, huffman=False) == result assert list(e.header_table.dynamic_entries) == []
def test_setting_table_size_to_the_same_does_nothing(self): e = Encoder() # Set the header table size to the default. e.header_table_size = 4096 # Now encode a header set. Just a small one, with a well-defined # output. header_set = [(':method', 'GET')] out = e.encode(header_set, huffman=True) assert out == b'\x82'
def test_resizing_header_table_sends_context_update(self): e = Encoder() # Resize the header table to a size so small that nothing can be in it. e.header_table_size = 40 # Now, encode a header set. Just a small one, with a well-defined # output. header_set = [(':method', 'GET')] out = e.encode(header_set, huffman=True) assert out == b'?\t\x82'