Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/spdy/hpack/hpack_decoder.h" | 5 #include "net/spdy/hpack/hpack_decoder.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 | 332 |
| 333 // Test a too-large indexed header. | 333 // Test a too-large indexed header. |
| 334 TEST_P(HpackDecoderTest, InvalidIndexedHeader) { | 334 TEST_P(HpackDecoderTest, InvalidIndexedHeader) { |
| 335 // High-bit set, and a prefix of one more than the number of static entries. | 335 // High-bit set, and a prefix of one more than the number of static entries. |
| 336 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\xbe", 1))); | 336 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\xbe", 1))); |
| 337 } | 337 } |
| 338 | 338 |
| 339 // Test that a header block with a pseudo-header field following a regular one | 339 // Test that a header block with a pseudo-header field following a regular one |
| 340 // is treated as malformed. (HTTP2 draft-14 8.1.2.1., HPACK draft-09 3.1.) | 340 // is treated as malformed. (HTTP2 draft-14 8.1.2.1., HPACK draft-09 3.1.) |
| 341 | 341 |
| 342 TEST_P(HpackDecoderTest, InvalidPseudoHeaderPositionStatic) { | 342 TEST_P(HpackDecoderTest, InvalidPseudoHeaderPositionStatic) { |
|
Bence
2016/05/31 15:57:02
Please remove these two tests entirely.
| |
| 343 // Okay: ":path" (static entry 4) followed by "allow" (static entry 20). | 343 // Okay: ":path" (static entry 4) followed by "allow" (static entry 20). |
| 344 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("8494"))); | 344 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("8494"))); |
| 345 // Malformed: "allow" (static entry 20) followed by ":path" (static entry 4). | 345 // Malformed: "allow" (static entry 20) followed by ":path" (static entry 4). |
| 346 EXPECT_FALSE(DecodeHeaderBlock(a2b_hex("9484"))); | 346 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("9484"))); |
| 347 } | 347 } |
| 348 | 348 |
| 349 TEST_P(HpackDecoderTest, InvalidPseudoHeaderPositionLiteral) { | 349 TEST_P(HpackDecoderTest, InvalidPseudoHeaderPositionLiteral) { |
| 350 // Okay: literal ":bar" followed by literal "foo". | 350 // Okay: literal ":bar" followed by literal "foo". |
| 351 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("40043a626172004003666f6f00"))); | 351 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("40043a626172004003666f6f00"))); |
| 352 // Malformed: literal "foo" followed by literal ":bar". | 352 // Malformed: literal "foo" followed by literal ":bar". |
| 353 EXPECT_FALSE(DecodeHeaderBlock(a2b_hex("4003666f6f0040043a62617200"))); | 353 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("4003666f6f0040043a62617200"))); |
| 354 } | 354 } |
| 355 | 355 |
| 356 TEST_P(HpackDecoderTest, ContextUpdateMaximumSize) { | 356 TEST_P(HpackDecoderTest, ContextUpdateMaximumSize) { |
| 357 EXPECT_EQ(kDefaultHeaderTableSizeSetting, | 357 EXPECT_EQ(kDefaultHeaderTableSizeSetting, |
| 358 decoder_peer_.header_table()->max_size()); | 358 decoder_peer_.header_table()->max_size()); |
| 359 string input; | 359 string input; |
| 360 { | 360 { |
| 361 // Maximum-size update with size 126. Succeeds. | 361 // Maximum-size update with size 126. Succeeds. |
| 362 HpackOutputStream output_stream; | 362 HpackOutputStream output_stream; |
| 363 output_stream.AppendPrefix(kHeaderTableSizeUpdateOpcode); | 363 output_stream.AppendPrefix(kHeaderTableSizeUpdateOpcode); |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 849 "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" | 849 "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" |
| 850 " max-age=3600; version=1"); | 850 " max-age=3600; version=1"); |
| 851 expectEntry(63, 52, "content-encoding", "gzip"); | 851 expectEntry(63, 52, "content-encoding", "gzip"); |
| 852 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT"); | 852 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT"); |
| 853 EXPECT_EQ(215u, decoder_peer_.header_table()->size()); | 853 EXPECT_EQ(215u, decoder_peer_.header_table()->size()); |
| 854 } | 854 } |
| 855 | 855 |
| 856 } // namespace | 856 } // namespace |
| 857 } // namespace test | 857 } // namespace test |
| 858 } // namespace net | 858 } // namespace net |
| OLD | NEW |