Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(898)

Side by Side Diff: net/spdy/hpack/hpack_decoder_test.cc

Issue 2028473003: Move header-ordering validation from hpack decoder to header validator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removes tests and HpackDecoder::regular_header_seen_. Adds header validation into HeaderCoalescer. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« net/spdy/header_coalescer.cc ('K') | « net/spdy/hpack/hpack_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698