| Index: net/spdy/hpack_decoder_test.cc
|
| diff --git a/net/spdy/hpack_decoder_test.cc b/net/spdy/hpack_decoder_test.cc
|
| index 2a5fce1402d08dcf7407f685ef963f5b400b27c2..dc261573cd8d623e82fb8aeec204e450fc231d63 100644
|
| --- a/net/spdy/hpack_decoder_test.cc
|
| +++ b/net/spdy/hpack_decoder_test.cc
|
| @@ -25,8 +25,7 @@ using std::string;
|
|
|
| class HpackDecoderPeer {
|
| public:
|
| - explicit HpackDecoderPeer(HpackDecoder* decoder)
|
| - : decoder_(decoder) {}
|
| + explicit HpackDecoderPeer(HpackDecoder* decoder) : decoder_(decoder) {}
|
|
|
| void HandleHeaderRepresentation(StringPiece name, StringPiece value) {
|
| decoder_->HandleHeaderRepresentation(name, value);
|
| @@ -34,21 +33,11 @@ class HpackDecoderPeer {
|
| bool DecodeNextName(HpackInputStream* in, StringPiece* out) {
|
| return decoder_->DecodeNextName(in, out);
|
| }
|
| - const HpackHeaderTable& header_table() {
|
| - return decoder_->header_table_;
|
| - }
|
| - void set_cookie_name(string name) {
|
| - decoder_->cookie_name_ = name;
|
| - }
|
| - string cookie_name() {
|
| - return decoder_->cookie_name_;
|
| - }
|
| - void set_cookie_value(string value) {
|
| - decoder_->cookie_value_ = value;
|
| - }
|
| - string cookie_value() {
|
| - return decoder_->cookie_value_;
|
| - }
|
| + const HpackHeaderTable& header_table() { return decoder_->header_table_; }
|
| + void set_cookie_name(string name) { decoder_->cookie_name_ = name; }
|
| + string cookie_name() { return decoder_->cookie_name_; }
|
| + void set_cookie_value(string value) { decoder_->cookie_value_ = value; }
|
| + string cookie_value() { return decoder_->cookie_value_; }
|
| const std::map<string, string>& decoded_block() const {
|
| return decoder_->decoded_block_;
|
| }
|
| @@ -75,12 +64,11 @@ const size_t kLiteralBound = 1024;
|
| class HpackDecoderTest : public ::testing::Test {
|
| protected:
|
| HpackDecoderTest()
|
| - : decoder_(ObtainHpackHuffmanTable()),
|
| - decoder_peer_(&decoder_) {}
|
| + : decoder_(ObtainHpackHuffmanTable()), decoder_peer_(&decoder_) {}
|
|
|
| bool DecodeHeaderBlock(StringPiece str) {
|
| return decoder_.HandleControlFrameHeadersData(0, str.data(), str.size()) &&
|
| - decoder_.HandleControlFrameHeadersComplete(0);
|
| + decoder_.HandleControlFrameHeadersComplete(0);
|
| }
|
| const std::map<string, string>& decoded_block() const {
|
| // TODO(jgraettinger): HpackDecoderTest should implement
|
| @@ -100,10 +88,10 @@ class HpackDecoderTest : public ::testing::Test {
|
|
|
| TEST_F(HpackDecoderTest, HandleControlFrameHeadersData) {
|
| // Strings under threshold are concatenated in the buffer.
|
| - EXPECT_TRUE(decoder_.HandleControlFrameHeadersData(
|
| - 0, "small string one", 16));
|
| - EXPECT_TRUE(decoder_.HandleControlFrameHeadersData(
|
| - 0, "small string two", 16));
|
| + EXPECT_TRUE(
|
| + decoder_.HandleControlFrameHeadersData(0, "small string one", 16));
|
| + EXPECT_TRUE(
|
| + decoder_.HandleControlFrameHeadersData(0, "small string two", 16));
|
| // A string which would push the buffer over the threshold is refused.
|
| EXPECT_FALSE(decoder_.HandleControlFrameHeadersData(
|
| 0, "fails", kMaxDecodeBufferSize - 32 + 1));
|
| @@ -124,10 +112,10 @@ TEST_F(HpackDecoderTest, HandleControlFrameHeadersComplete) {
|
| decoder_.HandleControlFrameHeadersData(0, NULL, 0);
|
| decoder_.HandleControlFrameHeadersComplete(0);
|
|
|
| - EXPECT_THAT(decoded_block(), ElementsAre(
|
| - Pair(":method", "GET"),
|
| - Pair(":path", "/index.html"),
|
| - Pair("CooKie", "foobar=baz")));
|
| + EXPECT_THAT(decoded_block(),
|
| + ElementsAre(Pair(":method", "GET"),
|
| + Pair(":path", "/index.html"),
|
| + Pair("CooKie", "foobar=baz")));
|
|
|
| EXPECT_EQ(decoder_peer_.cookie_name(), "");
|
| EXPECT_EQ(decoder_peer_.cookie_value(), "");
|
| @@ -163,13 +151,13 @@ TEST_F(HpackDecoderTest, HandleHeaderRepresentation) {
|
| // Finish and emit all headers.
|
| decoder_.HandleControlFrameHeadersComplete(0);
|
|
|
| - EXPECT_THAT(decoded_block(), ElementsAre(
|
| - Pair("cOOkie", " part 1; part 2 ; part3; fin!"),
|
| - Pair("empty", ""),
|
| - Pair("empty-joined", string("\0foo\0\0", 6)),
|
| - Pair("joineD", string("value 1\0value 2", 15)),
|
| - Pair("joined", "not joined"),
|
| - Pair("passed-through", string("foo\0baz", 7))));
|
| + EXPECT_THAT(decoded_block(),
|
| + ElementsAre(Pair("cOOkie", " part 1; part 2 ; part3; fin!"),
|
| + Pair("empty", ""),
|
| + Pair("empty-joined", string("\0foo\0\0", 6)),
|
| + Pair("joineD", string("value 1\0value 2", 15)),
|
| + Pair("joined", "not joined"),
|
| + Pair("passed-through", string("foo\0baz", 7))));
|
| }
|
|
|
| // Decoding an encoded name with a valid string literal should work.
|
| @@ -220,8 +208,7 @@ TEST_F(HpackDecoderTest, IndexedHeaderBasic) {
|
| // Toggle on static table entry #2 (and make a copy at index #1),
|
| // then toggle on static table entry #5 (which is now #6 because of
|
| // the copy of #2).
|
| - std::map<string, string> header_set1 =
|
| - DecodeUniqueHeaderSet("\x82\x86");
|
| + std::map<string, string> header_set1 = DecodeUniqueHeaderSet("\x82\x86");
|
| std::map<string, string> expected_header_set1;
|
| expected_header_set1[":method"] = "GET";
|
| expected_header_set1[":path"] = "/index.html";
|
| @@ -230,8 +217,7 @@ TEST_F(HpackDecoderTest, IndexedHeaderBasic) {
|
| std::map<string, string> expected_header_set2;
|
| expected_header_set2[":path"] = "/index.html";
|
| // Toggle off the copy of static table entry #5.
|
| - std::map<string, string> header_set2 =
|
| - DecodeUniqueHeaderSet("\x82");
|
| + std::map<string, string> header_set2 = DecodeUniqueHeaderSet("\x82");
|
| EXPECT_EQ(expected_header_set2, header_set2);
|
| }
|
|
|
| @@ -278,16 +264,14 @@ TEST_F(HpackDecoderTest, ContextUpdateMaximumSize) {
|
|
|
| TEST_F(HpackDecoderTest, ContextUpdateClearReferenceSet) {
|
| // Toggle on a couple of headers.
|
| - std::map<string, string> header_set1 =
|
| - DecodeUniqueHeaderSet("\x82\x86");
|
| + std::map<string, string> header_set1 = DecodeUniqueHeaderSet("\x82\x86");
|
| std::map<string, string> expected_header_set1;
|
| expected_header_set1[":method"] = "GET";
|
| expected_header_set1[":path"] = "/index.html";
|
| EXPECT_EQ(expected_header_set1, header_set1);
|
|
|
| // Send a context update to clear the reference set.
|
| - std::map<string, string> header_set2 =
|
| - DecodeUniqueHeaderSet("\x80\x80");
|
| + std::map<string, string> header_set2 = DecodeUniqueHeaderSet("\x80\x80");
|
| std::map<string, string> expected_header_set2;
|
| EXPECT_EQ(expected_header_set2, header_set2);
|
| }
|
| @@ -297,9 +281,8 @@ TEST_F(HpackDecoderTest, ContextUpdateClearReferenceSet) {
|
| TEST_F(HpackDecoderTest, LiteralHeaderNoIndexing) {
|
| // First header with indexed name, second header with string literal
|
| // name.
|
| - std::map<string, string> header_set =
|
| - DecodeUniqueHeaderSet(
|
| - "\x44\x0c/sample/path\x40\x06:path2\x0e/sample/path/2");
|
| + std::map<string, string> header_set = DecodeUniqueHeaderSet(
|
| + "\x44\x0c/sample/path\x40\x06:path2\x0e/sample/path/2");
|
|
|
| std::map<string, string> expected_header_set;
|
| expected_header_set[":path"] = "/sample/path";
|
| @@ -351,8 +334,8 @@ TEST_F(HpackDecoderTest, BasicE21) {
|
| expected_header_set[":authority"] = "www.example.com";
|
|
|
| string encoded_header_set;
|
| - EXPECT_TRUE(encoder.EncodeHeaderSet(
|
| - expected_header_set, &encoded_header_set));
|
| + EXPECT_TRUE(
|
| + encoder.EncodeHeaderSet(expected_header_set, &encoded_header_set));
|
|
|
| EXPECT_TRUE(DecodeHeaderBlock(encoded_header_set));
|
| EXPECT_EQ(expected_header_set, decoded_block());
|
| @@ -381,15 +364,15 @@ TEST_F(HpackDecoderTest, SectionD3RequestHuffmanExamples) {
|
| // | -> :authority: www.example.com
|
| char first[] =
|
| "\x82\x87\x86\x04\x8b\xdb\x6d\x88\x3e\x68\xd1\xcb\x12\x25\xba\x7f";
|
| - header_set = DecodeUniqueHeaderSet(StringPiece(first, arraysize(first)-1));
|
| + header_set = DecodeUniqueHeaderSet(StringPiece(first, arraysize(first) - 1));
|
|
|
| // TODO(jgraettinger): Create HpackEncodingContext and
|
| // HpackDecoder peers, and inspect the header table here.
|
| - EXPECT_THAT(header_set, ElementsAre(
|
| - Pair(":authority", "www.example.com"),
|
| - Pair(":method", "GET"),
|
| - Pair(":path", "/"),
|
| - Pair(":scheme", "http")));
|
| + EXPECT_THAT(header_set,
|
| + ElementsAre(Pair(":authority", "www.example.com"),
|
| + Pair(":method", "GET"),
|
| + Pair(":path", "/"),
|
| + Pair(":scheme", "http")));
|
|
|
| // 1b | == Literal indexed ==
|
| // | Indexed name (idx = 27)
|
| @@ -401,14 +384,15 @@ TEST_F(HpackDecoderTest, SectionD3RequestHuffmanExamples) {
|
| // | no-cache
|
| // | -> cache-control: no-cache
|
| char second[] = "\x1b\x86\x63\x65\x4a\x13\x98\xff";
|
| - header_set = DecodeUniqueHeaderSet(StringPiece(second, arraysize(second)-1));
|
| + header_set =
|
| + DecodeUniqueHeaderSet(StringPiece(second, arraysize(second) - 1));
|
|
|
| - EXPECT_THAT(header_set, ElementsAre(
|
| - Pair(":authority", "www.example.com"),
|
| - Pair(":method", "GET"),
|
| - Pair(":path", "/"),
|
| - Pair(":scheme", "http"),
|
| - Pair("cache-control", "no-cache")));
|
| + EXPECT_THAT(header_set,
|
| + ElementsAre(Pair(":authority", "www.example.com"),
|
| + Pair(":method", "GET"),
|
| + Pair(":path", "/"),
|
| + Pair(":scheme", "http"),
|
| + Pair("cache-control", "no-cache")));
|
|
|
| // 8080 | == Empty reference set ==
|
| // | idx = 0
|
| @@ -440,14 +424,14 @@ TEST_F(HpackDecoderTest, SectionD3RequestHuffmanExamples) {
|
| char third[] =
|
| "\x80\x80\x85\x8c\x8b\x84\x00\x88\x4e\xb0\x8b\x74\x97\x90\xfa\x7f\x89"
|
| "\x4e\xb0\x8b\x74\x97\x9a\x17\xa8\xff";
|
| - header_set = DecodeUniqueHeaderSet(StringPiece(third, arraysize(third)-1));
|
| -
|
| - EXPECT_THAT(header_set, ElementsAre(
|
| - Pair(":authority", "www.example.com"),
|
| - Pair(":method", "GET"),
|
| - Pair(":path", "/index.html"),
|
| - Pair(":scheme", "https"),
|
| - Pair("custom-key", "custom-value")));
|
| + header_set = DecodeUniqueHeaderSet(StringPiece(third, arraysize(third) - 1));
|
| +
|
| + EXPECT_THAT(header_set,
|
| + ElementsAre(Pair(":authority", "www.example.com"),
|
| + Pair(":method", "GET"),
|
| + Pair(":path", "/index.html"),
|
| + Pair(":scheme", "https"),
|
| + Pair("custom-key", "custom-value")));
|
| }
|
|
|
| TEST_F(HpackDecoderTest, SectionD5ResponseHuffmanExamples) {
|
| @@ -499,26 +483,27 @@ TEST_F(HpackDecoderTest, SectionD5ResponseHuffmanExamples) {
|
| "\x3a\x7a\x0e\x6e\x8f\xa2\x63\xd0\x72\x9a\x6e\x83\x97\xd8\x69\xbd\x87"
|
| "\x37\x47\xbb\xbf\xc7\x30\x90\xce\x31\x74\x3d\x80\x1b\x6d\xb1\x07\xcd"
|
| "\x1a\x39\x62\x44\xb7\x4f";
|
| - header_set = DecodeUniqueHeaderSet(StringPiece(first, arraysize(first)-1));
|
| + header_set = DecodeUniqueHeaderSet(StringPiece(first, arraysize(first) - 1));
|
|
|
| - EXPECT_THAT(header_set, ElementsAre(
|
| - Pair(":status", "302"),
|
| - Pair("cache-control", "private"),
|
| - Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"),
|
| - Pair("location", "https://www.example.com")));
|
| + EXPECT_THAT(header_set,
|
| + ElementsAre(Pair(":status", "302"),
|
| + Pair("cache-control", "private"),
|
| + Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"),
|
| + Pair("location", "https://www.example.com")));
|
|
|
| // 8c | == Indexed - Add ==
|
| // | idx = 12
|
| // | - evict: :status: 302
|
| // | -> :status: 200
|
| char second[] = "\x8c";
|
| - header_set = DecodeUniqueHeaderSet(StringPiece(second, arraysize(second)-1));
|
| + header_set =
|
| + DecodeUniqueHeaderSet(StringPiece(second, arraysize(second) - 1));
|
|
|
| - EXPECT_THAT(header_set, ElementsAre(
|
| - Pair(":status", "200"),
|
| - Pair("cache-control", "private"),
|
| - Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"),
|
| - Pair("location", "https://www.example.com")));
|
| + EXPECT_THAT(header_set,
|
| + ElementsAre(Pair(":status", "200"),
|
| + Pair("cache-control", "private"),
|
| + Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"),
|
| + Pair("location", "https://www.example.com")));
|
|
|
| // 84 | == Indexed - Remove ==
|
| // | idx = 4
|
| @@ -591,16 +576,17 @@ TEST_F(HpackDecoderTest, SectionD5ResponseHuffmanExamples) {
|
| "\xbf\xbe\xbf\xf3\xf7\xf4\xfb\x7e\xbb\xbe\x9f\x5f\x87\xe3\x7f\xef\xed"
|
| "\xfa\xee\xfa\x7c\x3f\x1d\x5d\x1a\x23\xce\x54\x64\x36\xcd\x49\x4b\xd5"
|
| "\xd1\xcc\x5f\x05\x35\x96\x9b";
|
| - header_set = DecodeUniqueHeaderSet(StringPiece(third, arraysize(third)-1));
|
| -
|
| - EXPECT_THAT(header_set, ElementsAre(
|
| - Pair(":status", "200"),
|
| - Pair("cache-control", "private"),
|
| - Pair("content-encoding", "gzip"),
|
| - Pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"),
|
| - Pair("location", "https://www.example.com"),
|
| - Pair("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;"
|
| - " max-age=3600; version=1")));
|
| + header_set = DecodeUniqueHeaderSet(StringPiece(third, arraysize(third) - 1));
|
| +
|
| + EXPECT_THAT(header_set,
|
| + ElementsAre(Pair(":status", "200"),
|
| + Pair("cache-control", "private"),
|
| + Pair("content-encoding", "gzip"),
|
| + Pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"),
|
| + Pair("location", "https://www.example.com"),
|
| + Pair("set-cookie",
|
| + "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;"
|
| + " max-age=3600; version=1")));
|
| }
|
|
|
| } // namespace
|
|
|