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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 354 |
355 // Test a too-large indexed header. | 355 // Test a too-large indexed header. |
356 TEST_P(HpackDecoderTest, InvalidIndexedHeader) { | 356 TEST_P(HpackDecoderTest, InvalidIndexedHeader) { |
357 // High-bit set, and a prefix of one more than the number of static entries. | 357 // High-bit set, and a prefix of one more than the number of static entries. |
358 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\xbe", 1))); | 358 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\xbe", 1))); |
359 } | 359 } |
360 | 360 |
361 // Test that a header block with a pseudo-header field following a regular one | 361 // Test that a header block with a pseudo-header field following a regular one |
362 // is treated as malformed. (HTTP2 draft-14 8.1.2.1., HPACK draft-09 3.1.) | 362 // is treated as malformed. (HTTP2 draft-14 8.1.2.1., HPACK draft-09 3.1.) |
363 | 363 |
364 TEST_P(HpackDecoderTest, InvalidPseudoHeaderPositionStatic) { | |
365 // Okay: ":path" (static entry 4) followed by "allow" (static entry 20). | |
366 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("8494"))); | |
367 // Malformed: "allow" (static entry 20) followed by ":path" (static entry 4). | |
368 EXPECT_FALSE(DecodeHeaderBlock(a2b_hex("9484"))); | |
369 } | |
370 | |
371 TEST_P(HpackDecoderTest, InvalidPseudoHeaderPositionLiteral) { | |
372 // Okay: literal ":bar" followed by literal "foo". | |
373 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("40043a626172004003666f6f00"))); | |
374 // Malformed: literal "foo" followed by literal ":bar". | |
375 EXPECT_FALSE(DecodeHeaderBlock(a2b_hex("4003666f6f0040043a62617200"))); | |
376 } | |
377 | |
378 TEST_P(HpackDecoderTest, ContextUpdateMaximumSize) { | 364 TEST_P(HpackDecoderTest, ContextUpdateMaximumSize) { |
379 EXPECT_EQ(kDefaultHeaderTableSizeSetting, | 365 EXPECT_EQ(kDefaultHeaderTableSizeSetting, |
380 decoder_peer_.header_table()->max_size()); | 366 decoder_peer_.header_table()->max_size()); |
381 string input; | 367 string input; |
382 { | 368 { |
383 // Maximum-size update with size 126. Succeeds. | 369 // Maximum-size update with size 126. Succeeds. |
384 HpackOutputStream output_stream; | 370 HpackOutputStream output_stream; |
385 output_stream.AppendPrefix(kHeaderTableSizeUpdateOpcode); | 371 output_stream.AppendPrefix(kHeaderTableSizeUpdateOpcode); |
386 output_stream.AppendUint32(126); | 372 output_stream.AppendUint32(126); |
387 | 373 |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" | 857 "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" |
872 " max-age=3600; version=1"); | 858 " max-age=3600; version=1"); |
873 expectEntry(63, 52, "content-encoding", "gzip"); | 859 expectEntry(63, 52, "content-encoding", "gzip"); |
874 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT"); | 860 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT"); |
875 EXPECT_EQ(215u, decoder_peer_.header_table()->size()); | 861 EXPECT_EQ(215u, decoder_peer_.header_table()->size()); |
876 } | 862 } |
877 | 863 |
878 } // namespace | 864 } // namespace |
879 } // namespace test | 865 } // namespace test |
880 } // namespace net | 866 } // namespace net |
OLD | NEW |