in neqo-qpack/src/decoder.rs [689:765]
fn header_block_decoder_huffman() {
let test_cases: [TestElement; 6] = [
// test a header with ref to static - encode_indexed
TestElement {
headers: vec![Header::new(":method", "GET")],
header_block: &[0x00, 0x00, 0xd1],
encoder_inst: &[],
},
// test encode_literal_with_name_ref
TestElement {
headers: vec![Header::new(":path", "/somewhere")],
header_block: &[
0x00, 0x00, 0x51, 0x87, 0x61, 0x07, 0xa4, 0xbe, 0x27, 0x2d, 0x85,
],
encoder_inst: &[],
},
// test adding a new header and encode_post_base_index, also test
// fix_header_block_prefix
TestElement {
headers: vec![Header::new("my-header", "my-value")],
header_block: &[0x02, 0x80, 0x10],
encoder_inst: &[
0x67, 0xa7, 0xd2, 0xd3, 0x94, 0x72, 0x16, 0xcf, 0x86, 0xa7, 0xd2, 0xdd, 0xc7,
0x45, 0xa5,
],
},
// test encode_indexed with a ref to dynamic table.
TestElement {
headers: vec![Header::new("my-header", "my-value")],
header_block: &[0x02, 0x00, 0x80],
encoder_inst: &[],
},
// test encode_literal_with_name_ref.
TestElement {
headers: vec![Header::new("my-header", "my-value2")],
header_block: &[
0x02, 0x00, 0x40, 0x87, 0xa7, 0xd2, 0xdd, 0xc7, 0x45, 0xa5, 0x17,
],
encoder_inst: &[],
},
// test multiple headers
TestElement {
headers: vec![
Header::new(":method", "GET"),
Header::new(":path", "/somewhere"),
Header::new(":authority", "example.com"),
Header::new(":scheme", "https"),
],
header_block: &[
0x00, 0x01, 0xd1, 0x51, 0x87, 0x61, 0x07, 0xa4, 0xbe, 0x27, 0x2d, 0x85, 0x50,
0x88, 0x2f, 0x91, 0xd3, 0x5d, 0x05, 0x5c, 0x87, 0xa7, 0xd7,
],
encoder_inst: &[],
},
];
let mut decoder = connect();
assert!(decoder.decoder.set_capacity(200).is_ok());
for (i, t) in test_cases.iter().enumerate() {
// receive an instruction.
if !t.encoder_inst.is_empty() {
recv_instruction(&mut decoder, t.encoder_inst, &Ok(()));
}
decode_headers(
&mut decoder,
t.header_block,
&t.headers,
StreamId::from(u64::try_from(i).unwrap()),
);
}
// test header acks and the insert count increment command
send_instructions_and_check(&mut decoder, &[0x03, 0x82, 0x83, 0x84]);
}