in neqo-qpack/src/decoder.rs [608:686]
fn header_block_decoder() {
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, 0x0a, 0x2f, 0x73, 0x6f, 0x6d, 0x65, 0x77, 0x68, 0x65, 0x72,
0x65,
],
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: &[
0x49, 0x6d, 0x79, 0x2d, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x08, 0x6d, 0x79,
0x2d, 0x76, 0x61, 0x6c, 0x75, 0x65,
],
},
// 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, 0x09, 0x6d, 0x79, 0x2d, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x32,
],
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, 0x0a, 0x2f, 0x73, 0x6f, 0x6d, 0x65, 0x77, 0x68, 0x65,
0x72, 0x65, 0x50, 0x0b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63,
0x6f, 0x6d, 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]);
}