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) { | |
343 // Okay: ":path" (static entry 4) followed by "allow" (static entry 20). | |
344 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("8494"))); | |
345 // Malformed: "allow" (static entry 20) followed by ":path" (static entry 4). | |
346 EXPECT_FALSE(DecodeHeaderBlock(a2b_hex("9484"))); | |
347 } | |
348 | |
349 TEST_P(HpackDecoderTest, InvalidPseudoHeaderPositionLiteral) { | |
350 // Okay: literal ":bar" followed by literal "foo". | |
351 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("40043a626172004003666f6f00"))); | |
352 // Malformed: literal "foo" followed by literal ":bar". | |
353 EXPECT_FALSE(DecodeHeaderBlock(a2b_hex("4003666f6f0040043a62617200"))); | |
354 } | |
355 | |
356 TEST_P(HpackDecoderTest, ContextUpdateMaximumSize) { | 342 TEST_P(HpackDecoderTest, ContextUpdateMaximumSize) { |
357 EXPECT_EQ(kDefaultHeaderTableSizeSetting, | 343 EXPECT_EQ(kDefaultHeaderTableSizeSetting, |
358 decoder_peer_.header_table()->max_size()); | 344 decoder_peer_.header_table()->max_size()); |
359 string input; | 345 string input; |
360 { | 346 { |
361 // Maximum-size update with size 126. Succeeds. | 347 // Maximum-size update with size 126. Succeeds. |
362 HpackOutputStream output_stream; | 348 HpackOutputStream output_stream; |
363 output_stream.AppendPrefix(kHeaderTableSizeUpdateOpcode); | 349 output_stream.AppendPrefix(kHeaderTableSizeUpdateOpcode); |
364 output_stream.AppendUint32(126); | 350 output_stream.AppendUint32(126); |
365 | 351 |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" | 835 "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" |
850 " max-age=3600; version=1"); | 836 " max-age=3600; version=1"); |
851 expectEntry(63, 52, "content-encoding", "gzip"); | 837 expectEntry(63, 52, "content-encoding", "gzip"); |
852 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT"); | 838 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT"); |
853 EXPECT_EQ(215u, decoder_peer_.header_table()->size()); | 839 EXPECT_EQ(215u, decoder_peer_.header_table()->size()); |
854 } | 840 } |
855 | 841 |
856 } // namespace | 842 } // namespace |
857 } // namespace test | 843 } // namespace test |
858 } // namespace net | 844 } // namespace net |
OLD | NEW |