| 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_decoder.h" | 5 #include "net/spdy/hpack_decoder.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 expected_header_set3["spam"] = "eggs"; | 250 expected_header_set3["spam"] = "eggs"; |
| 251 EXPECT_EQ(expected_header_set3, header_set3); | 251 EXPECT_EQ(expected_header_set3, header_set3); |
| 252 } | 252 } |
| 253 | 253 |
| 254 // Test a too-large indexed header. | 254 // Test a too-large indexed header. |
| 255 TEST_F(HpackDecoderTest, InvalidIndexedHeader) { | 255 TEST_F(HpackDecoderTest, InvalidIndexedHeader) { |
| 256 // High-bit set, and a prefix of one more than the number of static entries. | 256 // High-bit set, and a prefix of one more than the number of static entries. |
| 257 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\xbe", 1))); | 257 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\xbe", 1))); |
| 258 } | 258 } |
| 259 | 259 |
| 260 // Test that a header block with a pseudo-header field following a regular one |
| 261 // is treated as malformed. (HTTP2 draft-14 8.1.2.1., HPACK draft-09 3.1.) |
| 262 |
| 263 TEST_F(HpackDecoderTest, InvalidPseudoHeaderPositionStatic) { |
| 264 // Okay: ":path" (static entry 4) followed by "allow" (static entry 20). |
| 265 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("8494"))); |
| 266 // Malformed: "allow" (static entry 20) followed by ":path" (static entry 4). |
| 267 EXPECT_FALSE(DecodeHeaderBlock(a2b_hex("9484"))); |
| 268 } |
| 269 |
| 270 TEST_F(HpackDecoderTest, InvalidPseudoHeaderPositionLiteral) { |
| 271 // Okay: literal ":bar" followed by literal "foo". |
| 272 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("40043a626172004003666f6f00"))); |
| 273 // Malformed: literal "foo" followed by literal ":bar". |
| 274 EXPECT_FALSE(DecodeHeaderBlock(a2b_hex("4003666f6f0040043a62617200"))); |
| 275 } |
| 276 |
| 260 TEST_F(HpackDecoderTest, ContextUpdateMaximumSize) { | 277 TEST_F(HpackDecoderTest, ContextUpdateMaximumSize) { |
| 261 EXPECT_EQ(kDefaultHeaderTableSizeSetting, | 278 EXPECT_EQ(kDefaultHeaderTableSizeSetting, |
| 262 decoder_peer_.header_table()->max_size()); | 279 decoder_peer_.header_table()->max_size()); |
| 263 string input; | 280 string input; |
| 264 { | 281 { |
| 265 // Maximum-size update with size 126. Succeeds. | 282 // Maximum-size update with size 126. Succeeds. |
| 266 HpackOutputStream output_stream; | 283 HpackOutputStream output_stream; |
| 267 output_stream.AppendPrefix(kHeaderTableSizeUpdateOpcode); | 284 output_stream.AppendPrefix(kHeaderTableSizeUpdateOpcode); |
| 268 output_stream.AppendUint32(126); | 285 output_stream.AppendUint32(126); |
| 269 | 286 |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 expectEntry(62, 98, "set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" | 664 expectEntry(62, 98, "set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" |
| 648 " max-age=3600; version=1"); | 665 " max-age=3600; version=1"); |
| 649 expectEntry(63, 52, "content-encoding", "gzip"); | 666 expectEntry(63, 52, "content-encoding", "gzip"); |
| 650 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT"); | 667 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT"); |
| 651 EXPECT_EQ(215u, decoder_peer_.header_table()->size()); | 668 EXPECT_EQ(215u, decoder_peer_.header_table()->size()); |
| 652 } | 669 } |
| 653 | 670 |
| 654 } // namespace | 671 } // namespace |
| 655 | 672 |
| 656 } // namespace net | 673 } // namespace net |
| OLD | NEW |