Пример #1
0
 def test_request_huffman_decoder(self):
     decoder = HuffmanDecoder(REQUEST_CODES, REQUEST_CODES_LENGTH)
     assert decoder.decode(b'\xf1\xe3\xc2\xe5\xf2:k\xa0\xab\x90\xf4\xff'
                           ) == b"www.example.com"
     assert decoder.decode(b'\xa8\xeb\x10d\x9c\xbf') == b"no-cache"
     assert decoder.decode(b'%\xa8I\xe9[\xa9}\x7f') == b"custom-key"
     assert decoder.decode(
         b'%\xa8I\xe9[\xb8\xe8\xb4\xbf') == b"custom-value"
Пример #2
0
 def test_huffman_decoder_throws_useful_exceptions(self):
     # Specify a HuffmanDecoder with no values in it, then attempt to decode
     # using it.
     d = HuffmanDecoder([], [])
     with pytest.raises(HPACKDecodingError):
         d.decode(b'test')
Пример #3
0
 def test_request_huffman_decoder(self):
     decoder = HuffmanDecoder(REQUEST_CODES,REQUEST_CODES_LENGTH)
     assert decoder.decode(b'\xf1\xe3\xc2\xe5\xf2:k\xa0\xab\x90\xf4\xff') == b"www.example.com"
     assert decoder.decode(b'\xa8\xeb\x10d\x9c\xbf') == b"no-cache"
     assert decoder.decode(b'%\xa8I\xe9[\xa9}\x7f') == b"custom-key"
     assert decoder.decode(b'%\xa8I\xe9[\xb8\xe8\xb4\xbf') == b"custom-value"
Пример #4
0
 def test_eos_terminates_decode_request(self):
     decoder = HuffmanDecoder(REQUEST_CODES,REQUEST_CODES_LENGTH)
     assert decoder.decode(b'\xff\xff\xff\xfc') == b''
Пример #5
0
 def test_eos_terminates_decode_request(self):
     decoder = HuffmanDecoder(REQUEST_CODES, REQUEST_CODES_LENGTH)
     assert decoder.decode(b'\xff\xff\xff\xfc') == b''
Пример #6
0
 def test_huffman_decoder_throws_useful_exceptions(self):
     # Specify a HuffmanDecoder with no values in it, then attempt to decode
     # using it.
     d = HuffmanDecoder([], [])
     with pytest.raises(HPACKDecodingError):
         d.decode(b'test')