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

Side by Side Diff: net/spdy/header_coalescer_test.cc

Issue 2184253002: Reset HTTP/2 stream on line-folded response headers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re: #7. Created 4 years, 4 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
« no previous file with comments | « net/spdy/header_coalescer.cc ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "header_coalescer.h"
6
7 #include <string>
8
9 #include "base/strings/string_piece.h"
10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 using ::testing::ElementsAre;
14 using ::testing::Pair;
15
16 namespace net {
17 namespace test {
18
19 class HeaderCoalescerTest : public ::testing::Test {
20 public:
21 protected:
22 HeaderCoalescer header_coalescer_;
23 };
24
25 TEST_F(HeaderCoalescerTest, CorrectHeaders) {
26 header_coalescer_.OnHeader(":foo", "bar");
27 header_coalescer_.OnHeader("baz", "qux");
28 EXPECT_FALSE(header_coalescer_.error_seen());
29
30 SpdyHeaderBlock header_block = header_coalescer_.release_headers();
31 EXPECT_THAT(header_block,
32 ElementsAre(Pair(":foo", "bar"), Pair("baz", "qux")));
33 }
34
35 TEST_F(HeaderCoalescerTest, EmptyHeaderKey) {
36 EXPECT_FALSE(header_coalescer_.error_seen());
37 header_coalescer_.OnHeader("", "foo");
38 EXPECT_TRUE(header_coalescer_.error_seen());
39 }
40
41 TEST_F(HeaderCoalescerTest, HeaderBlockTooLarge) {
42 // 3 byte key, 256 * 1024 - 40 byte value, 32 byte overhead:
43 // less than 256 * 1024 bytes in total.
44 std::string data(256 * 1024 - 40, 'a');
45 header_coalescer_.OnHeader("foo", data);
46 EXPECT_FALSE(header_coalescer_.error_seen());
47
48 // Another 3 + 3 + 32 bytes: too large.
49 header_coalescer_.OnHeader("bar", "baz");
50 EXPECT_TRUE(header_coalescer_.error_seen());
51 }
52
53 TEST_F(HeaderCoalescerTest, PseudoHeadersMustNotFollowRegularHeaders) {
54 header_coalescer_.OnHeader("foo", "bar");
55 EXPECT_FALSE(header_coalescer_.error_seen());
56 header_coalescer_.OnHeader(":baz", "qux");
57 EXPECT_TRUE(header_coalescer_.error_seen());
58 }
59
60 TEST_F(HeaderCoalescerTest, Append) {
61 header_coalescer_.OnHeader("foo", "bar");
62 header_coalescer_.OnHeader("cookie", "baz");
63 header_coalescer_.OnHeader("foo", "quux");
64 header_coalescer_.OnHeader("cookie", "qux");
65 EXPECT_FALSE(header_coalescer_.error_seen());
66
67 SpdyHeaderBlock header_block = header_coalescer_.release_headers();
68 EXPECT_THAT(header_block,
69 ElementsAre(Pair("foo", base::StringPiece("bar\0quux", 8)),
70 Pair("cookie", "baz; qux")));
71 }
72
73 TEST_F(HeaderCoalescerTest, CRLFInHeaderValue) {
74 EXPECT_FALSE(header_coalescer_.error_seen());
75 header_coalescer_.OnHeader("foo", "bar\r\nbaz");
76 EXPECT_TRUE(header_coalescer_.error_seen());
77 }
78
79 } // namespace test
80 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/header_coalescer.cc ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698