### ----------------------------------------------------
### -- HTTP::HPACK
### -- Licenses: Artistic-2.0
### -- Authors: Jonathan Worthington
### -- File: t/examples.rakutest
### ----------------------------------------------------
### -- Chunk 2 of 2
4b, 0x61, 0x96, 0xd0, 0x7a, 0xbe, 0x94, 0x10, 0x54, 0xd4,
                0x44, 0xa8, 0x20, 0x05, 0x95, 0x04, 0x0b, 0x81, 0x66, 0xe0,
                0x82, 0xa6, 0x2d, 0x1b, 0xff, 0x6e, 0x91, 0x9d, 0x29, 0xad,
                0x17, 0x18, 0x63, 0xc7, 0x8f, 0x0b, 0x97, 0xc8, 0xe9, 0xae,
                0x82, 0xae, 0x43, 0xd3),
        'encoded first response header example (huffman coded)';
    is-deeply $encoder.encode-headers(
        [ header(':status', '307'), header('cache-control', 'private'),
          header('date', 'Mon, 21 Oct 2013 20:13:21 GMT'),
          header('location', 'https://www.example.com') ]),
        Buf.new(0x48, 0x83, 0x64, 0x0e, 0xff, 0xc1, 0xc0, 0xbf),
        'encoded second response header example (huffman coded)';
    is-deeply $encoder.encode-headers(
        [ header(':status', '200'), header('cache-control', 'private'),
          header('date', 'Mon, 21 Oct 2013 20:13:22 GMT'),
          header('location', 'https://www.example.com'),
          header('content-encoding', 'gzip'),
          header('set-cookie', 'foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1') ]),
        Buf.new(0x88, 0xc1, 0x61, 0x96, 0xd0, 0x7a, 0xbe, 0x94, 0x10, 0x54,
                0xd4, 0x44, 0xa8, 0x20, 0x05, 0x95, 0x04, 0x0b, 0x81, 0x66,
                0xe0, 0x84, 0xa6, 0x2d, 0x1b, 0xff, 0xc0, 0x5a, 0x83, 0x9b,
                0xd9, 0xab, 0x77, 0xad, 0x94, 0xe7, 0x82, 0x1d, 0xd7, 0xf2,
                0xe6, 0xc7, 0xb3, 0x35, 0xdf, 0xdf, 0xcd, 0x5b, 0x39, 0x60,
                0xd5, 0xaf, 0x27, 0x08, 0x7f, 0x36, 0x72, 0xc1, 0xab, 0x27,
                0x0f, 0xb5, 0x29, 0x1f, 0x95, 0x87, 0x31, 0x60, 0x65, 0xc0,
                0x03, 0xed, 0x4e, 0xe5, 0xb1, 0x06, 0x3d, 0x50, 0x07),
        'encoded third response header example (huffman coded)';
}

# Header table size update
{
    my $decoder = HTTP::HPACK::Decoder.new;
    $decoder.decode-headers(Buf.new(0x3f, 0x9a, 0x0a));
    is $decoder.dynamic-table-limit, 1337, 'Dynamic table size was increased';
    $decoder.decode-headers(Buf.new(42));
    is $decoder.dynamic-table-limit, 10, 'Dynamic table size was decreased';
}

done-testing;


