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

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

Issue 533073004: HPACK: Split header fields in encoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/hpack_encoder_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <cmath> 5 #include <cmath>
6 #include <ctime> 6 #include <ctime>
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 { 75 {
76 map<string, string> headers; 76 map<string, string> headers;
77 headers[":status"] = "200"; 77 headers[":status"] = "200";
78 headers["cache-control"] = "private"; 78 headers["cache-control"] = "private";
79 headers["content-encoding"] = "gzip"; 79 headers["content-encoding"] = "gzip";
80 headers["date"] = "Mon, 21 Oct 2013 20:13:22 GMT"; 80 headers["date"] = "Mon, 21 Oct 2013 20:13:22 GMT";
81 headers["location"] = "https://www.example.com"; 81 headers["location"] = "https://www.example.com";
82 headers["set-cookie"] = "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" 82 headers["set-cookie"] = "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;"
83 " max-age=3600; version=1"; 83 " max-age=3600; version=1";
84 headers["multivalue"] = string("foo\0bar", 7);
84 EXPECT_TRUE(RoundTrip(headers)); 85 EXPECT_TRUE(RoundTrip(headers));
85 } 86 }
86 } 87 }
87 88
88 TEST_F(HpackRoundTripTest, RequestFixtures) { 89 TEST_F(HpackRoundTripTest, RequestFixtures) {
89 { 90 {
90 map<string, string> headers; 91 map<string, string> headers;
91 headers[":authority"] = "www.example.com"; 92 headers[":authority"] = "www.example.com";
92 headers[":method"] = "GET"; 93 headers[":method"] = "GET";
93 headers[":path"] = "/"; 94 headers[":path"] = "/";
(...skipping 12 matching lines...) Expand all
106 EXPECT_TRUE(RoundTrip(headers)); 107 EXPECT_TRUE(RoundTrip(headers));
107 } 108 }
108 { 109 {
109 map<string, string> headers; 110 map<string, string> headers;
110 headers[":authority"] = "www.example.com"; 111 headers[":authority"] = "www.example.com";
111 headers[":method"] = "GET"; 112 headers[":method"] = "GET";
112 headers[":path"] = "/index.html"; 113 headers[":path"] = "/index.html";
113 headers[":scheme"] = "https"; 114 headers[":scheme"] = "https";
114 headers["custom-key"] = "custom-value"; 115 headers["custom-key"] = "custom-value";
115 headers["cookie"] = "baz=bing; fizzle=fazzle; garbage"; 116 headers["cookie"] = "baz=bing; fizzle=fazzle; garbage";
117 headers["multivalue"] = string("foo\0bar", 7);
116 EXPECT_TRUE(RoundTrip(headers)); 118 EXPECT_TRUE(RoundTrip(headers));
117 } 119 }
118 } 120 }
119 121
120 TEST_F(HpackRoundTripTest, RandomizedExamples) { 122 TEST_F(HpackRoundTripTest, RandomizedExamples) {
121 // Grow vectors of names & values, which are seeded with fixtures and then 123 // Grow vectors of names & values, which are seeded with fixtures and then
122 // expanded with dynamically generated data. Samples are taken using the 124 // expanded with dynamically generated data. Samples are taken using the
123 // exponential distribution. 125 // exponential distribution.
124 vector<string> names; 126 vector<string> names;
125 names.push_back(":authority"); 127 names.push_back(":authority");
(...skipping 24 matching lines...) Expand all
150 size_t value_index = SampleExponential(20, 200); 152 size_t value_index = SampleExponential(20, 200);
151 153
152 string name, value; 154 string name, value;
153 if (name_index >= names.size()) { 155 if (name_index >= names.size()) {
154 names.push_back(base::RandBytesAsString(1 + SampleExponential(5, 30))); 156 names.push_back(base::RandBytesAsString(1 + SampleExponential(5, 30)));
155 name = names.back(); 157 name = names.back();
156 } else { 158 } else {
157 name = names[name_index]; 159 name = names[name_index];
158 } 160 }
159 if (value_index >= values.size()) { 161 if (value_index >= values.size()) {
160 values.push_back(base::RandBytesAsString( 162 string newvalue =
161 1 + SampleExponential(15, 75))); 163 base::RandBytesAsString(1 + SampleExponential(15, 75));
164 // Currently order is not preserved in the encoder. In particular,
165 // when a value is decomposed at \0 delimiters, its parts might get
166 // encoded out of order if some but not all of them already exist in
167 // the header table. For now, avoid \0 bytes in values.
168 std::replace(newvalue.begin(), newvalue.end(), '\x00', '\x01');
169 values.push_back(newvalue);
162 value = values.back(); 170 value = values.back();
163 } else { 171 } else {
164 value = values[value_index]; 172 value = values[value_index];
165 } 173 }
166 headers[name] = value; 174 headers[name] = value;
167 } 175 }
168 EXPECT_TRUE(RoundTrip(headers)); 176 EXPECT_TRUE(RoundTrip(headers));
169 } 177 }
170 } 178 }
171 179
172 } // namespace 180 } // namespace
173 181
174 } // namespace net 182 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/hpack_encoder_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698