TS-4063: Add regression tests for HPACK Huffman This closes #372
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/d5307c6d Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/d5307c6d Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/d5307c6d Branch: refs/heads/master Commit: d5307c6d5b7d1414550f4d618e69a4161d1f147e Parents: 9894fb1 c98b51f Author: Masakazu Kitajo <mkita...@yahoo-corp.jp> Authored: Thu Dec 10 10:02:45 2015 +0900 Committer: Masaori Koshiba <masa...@apache.org> Committed: Thu Dec 10 10:08:10 2015 +0900 ---------------------------------------------------------------------- proxy/http2/RegressionHPACK.cc | 84 +++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d5307c6d/proxy/http2/RegressionHPACK.cc ---------------------------------------------------------------------- diff --cc proxy/http2/RegressionHPACK.cc index f4e8da8,c1021d0..5ceebc8 --- a/proxy/http2/RegressionHPACK.cc +++ b/proxy/http2/RegressionHPACK.cc @@@ -110,19 -110,60 +110,65 @@@ const static struct {(char *)"password", (char *) "secret", 0, HPACK_FIELD_NEVERINDEX_LITERAL, (uint8_t *) "\x10\x08" "password\x06" "secret", - 17}}; + 17}, + // with Huffman Coding - {(char *)"custom-key", (char *) "custom-header", 0, HPACK_FIELD_INDEXED_LITERAL, (uint8_t *) "\x40" - "\x88\x25\xa8\x49\xe9\x5b\xa9\x7d\x7f" - "\x89\x25\xa8\x49\xe9\x5a\x72\x8e\x42\xd9", ++ {(char *)"custom-key", (char *) "custom-header", 0, HPACK_FIELD_INDEXED_LITERAL, ++ (uint8_t *) "\x40" ++ "\x88\x25\xa8\x49\xe9\x5b\xa9\x7d\x7f" ++ "\x89\x25\xa8\x49\xe9\x5a\x72\x8e\x42\xd9", + 20}, - {(char *)"custom-key", (char *) "custom-header", 0, HPACK_FIELD_NOINDEX_LITERAL, (uint8_t *) "\x00" - "\x88\x25\xa8\x49\xe9\x5b\xa9\x7d\x7f" - "\x89\x25\xa8\x49\xe9\x5a\x72\x8e\x42\xd9", ++ {(char *)"custom-key", (char *) "custom-header", 0, HPACK_FIELD_NOINDEX_LITERAL, ++ (uint8_t *) "\x00" ++ "\x88\x25\xa8\x49\xe9\x5b\xa9\x7d\x7f" ++ "\x89\x25\xa8\x49\xe9\x5a\x72\x8e\x42\xd9", + 20}, - {(char *)"custom-key", (char *) "custom-header", 0, HPACK_FIELD_NEVERINDEX_LITERAL, (uint8_t *) "\x10" - "\x88\x25\xa8\x49\xe9\x5b\xa9\x7d\x7f" - "\x89\x25\xa8\x49\xe9\x5a\x72\x8e\x42\xd9", ++ {(char *)"custom-key", (char *) "custom-header", 0, HPACK_FIELD_NEVERINDEX_LITERAL, ++ (uint8_t *) "\x10" ++ "\x88\x25\xa8\x49\xe9\x5b\xa9\x7d\x7f" ++ "\x89\x25\xa8\x49\xe9\x5a\x72\x8e\x42\xd9", + 20}, + {(char *)":path", (char *) "/sample/path", 4, HPACK_FIELD_INDEXED_LITERAL, (uint8_t *) "\x44" + "\x89\x61\x03\xa6\xba\x0a\xc5\x63\x4c\xff", + 11}, + {(char *)":path", (char *) "/sample/path", 4, HPACK_FIELD_NOINDEX_LITERAL, (uint8_t *) "\x04" + "\x89\x61\x03\xa6\xba\x0a\xc5\x63\x4c\xff", + 11}, - {(char *)":path", (char *) "/sample/path", 4, HPACK_FIELD_NEVERINDEX_LITERAL, (uint8_t *) "\x14" - "\x89\x61\x03\xa6\xba\x0a\xc5\x63\x4c\xff", ++ {(char *)":path", (char *) "/sample/path", 4, HPACK_FIELD_NEVERINDEX_LITERAL, ++ (uint8_t *) "\x14" ++ "\x89\x61\x03\xa6\xba\x0a\xc5\x63\x4c\xff", + 11}, + {(char *)"password", (char *) "secret", 0, HPACK_FIELD_INDEXED_LITERAL, (uint8_t *) "\x40" + "\x86\xac\x68\x47\x83\xd9\x27" + "\x84\x41\x49\x61\x53", + 13}, + {(char *)"password", (char *) "secret", 0, HPACK_FIELD_NOINDEX_LITERAL, (uint8_t *) "\x00" + "\x86\xac\x68\x47\x83\xd9\x27" + "\x84\x41\x49\x61\x53", + 13}, + {(char *)"password", (char *) "secret", 0, HPACK_FIELD_NEVERINDEX_LITERAL, (uint8_t *) "\x10" + "\x86\xac\x68\x47\x83\xd9\x27" + "\x84\x41\x49\x61\x53", + 13}}; // [RFC 7541] C.3. Request Examples without Huffman Coding - C.3.1. First Request + // [RFC 7541] C.4. Request Examples with Huffman Coding - C.4.1. First Request const static struct { char *raw_name; char *raw_value; } raw_field_test_case[][MAX_TEST_FIELD_NUM] = {{ - {(char *)":method", (char *) "GET"}, - {(char *)":scheme", (char *) "http"}, - {(char *)":path", (char *) "/"}, - {(char *)":authority", (char *) "www.example.com"}, - {(char *)"", (char *) ""} // End of this test case -},{ -- {(char *)":method", (char *) "GET"}, -- {(char *)":scheme", (char *) "http"}, -- {(char *)":path", (char *) "/"}, -- {(char *)":authority", (char *) "www.example.com"}, -- {(char *)"", (char *) ""} // End of this test case --}}; ++ {(char *)":method", (char *) "GET"}, ++ {(char *)":scheme", (char *) "http"}, ++ {(char *)":path", (char *) "/"}, ++ {(char *)":authority", (char *) "www.example.com"}, ++ {(char *)"", (char *) ""} // End of this test case ++ }, ++ { ++ {(char *)":method", (char *) "GET"}, ++ {(char *)":scheme", (char *) "http"}, ++ {(char *)":path", (char *) "/"}, ++ {(char *)":authority", (char *) "www.example.com"}, ++ {(char *)"", (char *) ""} // End of this test case ++ }}; const static struct { uint8_t *encoded_field; int encoded_field_len; @@@ -138,8 -179,23 +184,22 @@@ "\x40" "\xa:authority" "\xfwww.example.com", - 64}}; + 64}, - {(uint8_t *)"\x40" ++ {(uint8_t *)"\x40" + "\x85\xb9\x49\x53\x39\xe4" + "\x83\xc5\x83\x7f" + "\x40" + "\x85\xb8\x82\x4e\x5a\x4b" + "\x83\x9d\x29\xaf" + "\x40" + "\x84\xb9\x58\xd3\x3f" + "\x81\x63" + "\x40" + "\x88\xb8\x3b\x53\x39\xec\x32\x7d\x7f" + "\x8c\xf1\xe3\xc2\xe5\xf2\x3a\x6b\xa0\xab\x90\xf4\xff", + 53}}; + - /*********************************************************************************** * * * Regression test codes *