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 "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" | 5 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" |
6 | 6 |
7 #include "net/http/http_response_headers.h" | 7 #include "net/http/http_response_headers.h" |
8 #include "net/proxy/proxy_service.h" | 8 #include "net/proxy/proxy_service.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 // Transform "normal"-looking headers (\n-separated) to the appropriate | 13 // Transform "normal"-looking headers (\n-separated) to the appropriate |
14 // input format for ParseRawHeaders (\0-separated). | 14 // input format for ParseRawHeaders (\0-separated). |
15 void HeadersToRaw(std::string* headers) { | 15 void HeadersToRaw(std::string* headers) { |
16 std::replace(headers->begin(), headers->end(), '\n', '\0'); | 16 std::replace(headers->begin(), headers->end(), '\n', '\0'); |
17 if (!headers->empty()) | 17 if (!headers->empty()) |
18 *headers += '\0'; | 18 *headers += '\0'; |
19 } | 19 } |
20 | 20 |
21 } // namespace | 21 } // namespace |
22 | 22 |
23 namespace data_reduction_proxy { | 23 namespace data_reduction_proxy { |
24 | 24 |
25 class DataReductionProxyHeadersTest : public testing::Test {}; | 25 class DataReductionProxyHeadersTest : public testing::Test {}; |
26 | 26 |
27 TEST_F(DataReductionProxyHeadersTest, GetDataReductionProxyActionValue) { | |
28 const struct { | |
29 const char* headers; | |
30 std::string action_key; | |
31 bool expected_result; | |
32 std::string expected_action_value; | |
33 } tests[] = { | |
34 { "HTTP/1.1 200 OK\n" | |
35 "Content-Length: 999\n", | |
36 "a", | |
37 false, | |
38 "", | |
39 }, | |
40 { "HTTP/1.1 200 OK\n" | |
41 "connection: keep-alive\n" | |
42 "Content-Length: 999\n", | |
43 "a", | |
44 false, | |
45 "", | |
46 }, | |
47 { "HTTP/1.1 200 OK\n" | |
48 "connection: keep-alive\n" | |
49 "Chrome-Proxy: bypass=86400\n" | |
50 "Content-Length: 999\n", | |
51 "bypass", | |
52 true, | |
53 "86400", | |
54 }, | |
55 { "HTTP/1.1 200 OK\n" | |
56 "connection: keep-alive\n" | |
57 "Chrome-Proxy: bypass86400\n" | |
58 "Content-Length: 999\n", | |
59 "bypass", | |
60 false, | |
61 "", | |
62 }, | |
63 { "HTTP/1.1 200 OK\n" | |
64 "connection: keep-alive\n" | |
65 "Chrome-Proxy: bypass=0\n" | |
66 "Content-Length: 999\n", | |
67 "bypass", | |
68 true, | |
69 "0", | |
70 }, | |
71 { "HTTP/1.1 200 OK\n" | |
72 "connection: keep-alive\n" | |
73 "Chrome-Proxy: bypass=1500\n" | |
74 "Chrome-Proxy: bypass=86400\n" | |
75 "Content-Length: 999\n", | |
76 "bypass", | |
77 true, | |
78 "1500", | |
79 }, | |
80 { "HTTP/1.1 200 OK\n" | |
81 "connection: keep-alive\n" | |
82 "Chrome-Proxy: block=1500, block=3600\n" | |
83 "Content-Length: 999\n", | |
84 "block", | |
85 true, | |
86 "1500", | |
87 }, | |
88 { "HTTP/1.1 200 OK\n" | |
89 "connection: proxy-bypass\n" | |
90 "Chrome-Proxy: key=123 \n" | |
91 "Content-Length: 999\n", | |
92 "key", | |
93 true, | |
94 "123", | |
95 }, | |
96 }; | |
97 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | |
98 std::string headers(tests[i].headers); | |
99 HeadersToRaw(&headers); | |
100 scoped_refptr<net::HttpResponseHeaders> parsed( | |
101 new net::HttpResponseHeaders(headers)); | |
102 | |
103 std::string action_value; | |
104 bool has_action_key = GetDataReductionProxyActionValue( | |
105 parsed, tests[i].action_key, &action_value); | |
106 EXPECT_EQ(tests[i].expected_result, has_action_key); | |
107 if (has_action_key) { | |
108 EXPECT_EQ(tests[i].expected_action_value, action_value); | |
109 } | |
110 } | |
111 } | |
112 | |
27 TEST_F(DataReductionProxyHeadersTest, GetProxyBypassInfo) { | 113 TEST_F(DataReductionProxyHeadersTest, GetProxyBypassInfo) { |
28 const struct { | 114 const struct { |
29 const char* headers; | 115 const char* headers; |
30 bool expected_result; | 116 bool expected_result; |
31 int64 expected_retry_delay; | 117 int64 expected_retry_delay; |
32 bool expected_bypass_all; | 118 bool expected_bypass_all; |
33 } tests[] = { | 119 } tests[] = { |
34 { "HTTP/1.1 200 OK\n" | 120 { "HTTP/1.1 200 OK\n" |
35 "Content-Length: 999\n", | 121 "Content-Length: 999\n", |
36 false, | 122 false, |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 | 281 |
196 DataReductionProxyInfo data_reduction_proxy_info; | 282 DataReductionProxyInfo data_reduction_proxy_info; |
197 EXPECT_TRUE(ParseHeadersAndSetProxyInfo(parsed, &data_reduction_proxy_info)); | 283 EXPECT_TRUE(ParseHeadersAndSetProxyInfo(parsed, &data_reduction_proxy_info)); |
198 EXPECT_LE(60, data_reduction_proxy_info.bypass_duration.InSeconds()); | 284 EXPECT_LE(60, data_reduction_proxy_info.bypass_duration.InSeconds()); |
199 EXPECT_GE(5 * 60, data_reduction_proxy_info.bypass_duration.InSeconds()); | 285 EXPECT_GE(5 * 60, data_reduction_proxy_info.bypass_duration.InSeconds()); |
200 EXPECT_FALSE(data_reduction_proxy_info.bypass_all); | 286 EXPECT_FALSE(data_reduction_proxy_info.bypass_all); |
201 } | 287 } |
202 | 288 |
203 TEST_F(DataReductionProxyHeadersTest, HasDataReductionProxyViaHeader) { | 289 TEST_F(DataReductionProxyHeadersTest, HasDataReductionProxyViaHeader) { |
204 const struct { | 290 const struct { |
205 const char* headers; | 291 const char* headers; |
206 bool expected_result; | 292 bool expected_result; |
293 bool expected_has_intermediary; | |
294 bool is_has_intermediary_null; | |
bengr
2014/08/04 16:32:11
is_has_intermediary_null --> ignore_intermediary
xingx1
2014/08/04 17:24:32
Done.
| |
207 } tests[] = { | 295 } tests[] = { |
208 { "HTTP/1.1 200 OK\n" | 296 { "HTTP/1.1 200 OK\n" |
209 "Via: 1.1 Chrome-Proxy\n", | 297 "Via: 1.1 Chrome-Proxy\n", |
210 false, | 298 false, |
299 false, | |
300 false, | |
211 }, | 301 }, |
212 { "HTTP/1.1 200 OK\n" | 302 { "HTTP/1.1 200 OK\n" |
213 "Via: 1\n", | 303 "Via: 1\n", |
214 false, | 304 false, |
305 false, | |
306 false, | |
215 }, | 307 }, |
216 { "HTTP/1.1 200 OK\n" | 308 { "HTTP/1.1 200 OK\n" |
217 "Via: 1.1 Chrome-Compression-Proxy\n", | 309 "Via: 1.1 Chrome-Compression-Proxy\n", |
218 true, | 310 true, |
311 true, | |
312 false, | |
219 }, | 313 }, |
220 { "HTTP/1.1 200 OK\n" | 314 { "HTTP/1.1 200 OK\n" |
221 "Via: 1.0 Chrome-Compression-Proxy\n", | 315 "Via: 1.0 Chrome-Compression-Proxy\n", |
222 true, | 316 true, |
317 true, | |
318 false, | |
223 }, | 319 }, |
224 { "HTTP/1.1 200 OK\n" | 320 { "HTTP/1.1 200 OK\n" |
225 "Via: 1.1 Foo-Bar, 1.1 Chrome-Compression-Proxy\n", | 321 "Via: 1.1 Foo-Bar, 1.1 Chrome-Compression-Proxy\n", |
226 true, | 322 true, |
323 true, | |
324 false, | |
227 }, | 325 }, |
228 { "HTTP/1.1 200 OK\n" | 326 { "HTTP/1.1 200 OK\n" |
229 "Via: 1.1 Chrome-Compression-Proxy, 1.1 Bar-Foo\n", | 327 "Via: 1.1 Chrome-Compression-Proxy, 1.1 Bar-Foo\n", |
230 true, | 328 true, |
329 false, | |
330 false, | |
231 }, | 331 }, |
232 { "HTTP/1.1 200 OK\n" | 332 { "HTTP/1.1 200 OK\n" |
233 "Via: 1.1 chrome-compression-proxy\n", | 333 "Via: 1.1 chrome-compression-proxy\n", |
234 false, | 334 false, |
335 false, | |
336 false, | |
235 }, | 337 }, |
236 { "HTTP/1.1 200 OK\n" | 338 { "HTTP/1.1 200 OK\n" |
237 "Via: 1.1 Foo-Bar\n" | 339 "Via: 1.1 Foo-Bar\n" |
238 "Via: 1.1 Chrome-Compression-Proxy\n", | 340 "Via: 1.1 Chrome-Compression-Proxy\n", |
239 true, | 341 true, |
342 true, | |
343 false, | |
344 }, | |
345 { "HTTP/1.1 200 OK\n" | |
346 "Via: 1.1 Chrome-Compression-Proxy\n" | |
347 "Via: 1.1 Foo-Bar\n", | |
348 true, | |
349 false, | |
350 false, | |
240 }, | 351 }, |
241 { "HTTP/1.1 200 OK\n" | 352 { "HTTP/1.1 200 OK\n" |
242 "Via: 1.1 Chrome-Proxy\n", | 353 "Via: 1.1 Chrome-Proxy\n", |
243 false, | 354 false, |
355 false, | |
356 false, | |
244 }, | 357 }, |
245 { "HTTP/1.1 200 OK\n" | 358 { "HTTP/1.1 200 OK\n" |
246 "Via: 1.1 Chrome Compression Proxy\n", | 359 "Via: 1.1 Chrome Compression Proxy\n", |
247 true, | 360 true, |
361 true, | |
362 false, | |
248 }, | 363 }, |
249 { "HTTP/1.1 200 OK\n" | 364 { "HTTP/1.1 200 OK\n" |
250 "Via: 1.1 Foo-Bar, 1.1 Chrome Compression Proxy\n", | 365 "Via: 1.1 Foo-Bar, 1.1 Chrome Compression Proxy\n", |
251 true, | 366 true, |
367 true, | |
368 false, | |
252 }, | 369 }, |
253 { "HTTP/1.1 200 OK\n" | 370 { "HTTP/1.1 200 OK\n" |
254 "Via: 1.1 Chrome Compression Proxy, 1.1 Bar-Foo\n", | 371 "Via: 1.1 Chrome Compression Proxy, 1.1 Bar-Foo\n", |
255 true, | 372 true, |
373 false, | |
374 false, | |
256 }, | 375 }, |
257 { "HTTP/1.1 200 OK\n" | 376 { "HTTP/1.1 200 OK\n" |
258 "Via: 1.1 chrome compression proxy\n", | 377 "Via: 1.1 chrome compression proxy\n", |
259 false, | 378 false, |
379 false, | |
380 false, | |
260 }, | 381 }, |
261 { "HTTP/1.1 200 OK\n" | 382 { "HTTP/1.1 200 OK\n" |
262 "Via: 1.1 Foo-Bar\n" | 383 "Via: 1.1 Foo-Bar\n" |
263 "Via: 1.1 Chrome Compression Proxy\n", | 384 "Via: 1.1 Chrome Compression Proxy\n", |
264 true, | 385 true, |
386 true, | |
387 false, | |
388 }, | |
389 { "HTTP/1.1 200 OK\n" | |
390 "Via: 1.1 Chrome Compression Proxy\n" | |
391 "Via: 1.1 Foo-Bar\n", | |
392 true, | |
393 false, | |
394 false, | |
395 }, | |
396 { "HTTP/1.1 200 OK\n" | |
397 "Via: 1.1 Chrome Compression Proxy\n" | |
398 "Via: 1.1 Foo-Bar\n", | |
399 true, | |
400 false, | |
401 true, | |
265 }, | 402 }, |
266 }; | 403 }; |
267 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 404 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
268 std::string headers(tests[i].headers); | 405 std::string headers(tests[i].headers); |
269 HeadersToRaw(&headers); | 406 HeadersToRaw(&headers); |
270 scoped_refptr<net::HttpResponseHeaders> parsed( | 407 scoped_refptr<net::HttpResponseHeaders> parsed( |
271 new net::HttpResponseHeaders(headers)); | 408 new net::HttpResponseHeaders(headers)); |
272 | 409 |
273 EXPECT_EQ(tests[i].expected_result, | 410 bool has, has_intermediary; |
bengr
2014/08/04 16:32:11
has -> has_chrome_proxy_via_header
xingx1
2014/08/04 17:24:32
Done.
| |
274 HasDataReductionProxyViaHeader(parsed)); | 411 if (tests[i].is_has_intermediary_null) |
412 has = HasDataReductionProxyViaHeader(parsed, NULL); | |
413 else | |
414 has = HasDataReductionProxyViaHeader(parsed, &has_intermediary); | |
415 EXPECT_EQ(tests[i].expected_result, has); | |
416 if (has && !tests[i].is_has_intermediary_null) { | |
417 EXPECT_EQ(tests[i].expected_has_intermediary, has_intermediary); | |
418 } | |
275 } | 419 } |
276 } | 420 } |
277 | 421 |
278 TEST_F(DataReductionProxyHeadersTest, GetDataReductionProxyBypassEventType) { | 422 TEST_F(DataReductionProxyHeadersTest, GetDataReductionProxyBypassEventType) { |
279 const struct { | 423 const struct { |
280 const char* headers; | 424 const char* headers; |
281 net::ProxyService::DataReductionProxyBypassType expected_result; | 425 net::ProxyService::DataReductionProxyBypassType expected_result; |
282 } tests[] = { | 426 } tests[] = { |
283 { "HTTP/1.1 200 OK\n" | 427 { "HTTP/1.1 200 OK\n" |
284 "Chrome-Proxy: bypass=0\n" | 428 "Chrome-Proxy: bypass=0\n" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 518 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
375 std::string headers(tests[i].headers); | 519 std::string headers(tests[i].headers); |
376 HeadersToRaw(&headers); | 520 HeadersToRaw(&headers); |
377 scoped_refptr<net::HttpResponseHeaders> parsed( | 521 scoped_refptr<net::HttpResponseHeaders> parsed( |
378 new net::HttpResponseHeaders(headers)); | 522 new net::HttpResponseHeaders(headers)); |
379 DataReductionProxyInfo chrome_proxy_info; | 523 DataReductionProxyInfo chrome_proxy_info; |
380 EXPECT_EQ(tests[i].expected_result, | 524 EXPECT_EQ(tests[i].expected_result, |
381 GetDataReductionProxyBypassType(parsed, &chrome_proxy_info)); | 525 GetDataReductionProxyBypassType(parsed, &chrome_proxy_info)); |
382 } | 526 } |
383 } | 527 } |
528 | |
529 TEST_F(DataReductionProxyHeadersTest, | |
530 GetDataReductionProxyActionFingerprintChromeProxy) { | |
531 const struct { | |
532 std::string label; | |
533 const char* headers; | |
534 bool expected_fingerprint_exist; | |
535 std::string expected_fingerprint; | |
536 } tests[] = { | |
537 { "fingerprint doesn't exist", | |
538 "HTTP/1.1 200 OK\n" | |
539 "Chrome-Proxy: bypass=0\n", | |
540 false, | |
541 "", | |
542 }, | |
543 { "fingerprint occurs once", | |
544 "HTTP/1.1 200 OK\n" | |
545 "Chrome-Proxy: bypass=1, fcp=fp\n", | |
546 true, | |
547 "fp", | |
548 }, | |
549 { "fingerprint occurs twice", | |
550 "HTTP/1.1 200 OK\n" | |
551 "Chrome-Proxy: bypass=2, fcp=fp1, fcp=fp2\n", | |
552 true, | |
553 "fp1", | |
554 }, | |
555 }; | |
556 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | |
557 std::string headers(tests[i].headers); | |
558 HeadersToRaw(&headers); | |
559 scoped_refptr<net::HttpResponseHeaders> parsed( | |
560 new net::HttpResponseHeaders(headers)); | |
561 | |
562 std::string fingerprint; | |
563 bool fingerprint_exist = GetDataReductionProxyActionFingerprintChromeProxy( | |
564 parsed, &fingerprint); | |
565 EXPECT_EQ(tests[i].expected_fingerprint_exist, fingerprint_exist) | |
566 << tests[i].label; | |
567 | |
568 if (fingerprint_exist) | |
569 EXPECT_EQ(tests[i].expected_fingerprint, fingerprint) << tests[i].label; | |
570 } | |
571 } | |
572 | |
573 TEST_F(DataReductionProxyHeadersTest, | |
574 GetDataReductionProxyActionFingerprintVia) { | |
575 const struct { | |
576 std::string label; | |
577 const char* headers; | |
578 bool expected_fingerprint_exist; | |
579 std::string expected_fingerprint; | |
580 } tests[] = { | |
581 { "fingerprint doesn't exist", | |
582 "HTTP/1.1 200 OK\n" | |
583 "Chrome-Proxy: bypass=0\n", | |
584 false, | |
585 "", | |
586 }, | |
587 { "fingerprint occurs once", | |
588 "HTTP/1.1 200 OK\n" | |
589 "Chrome-Proxy: bypass=1, fvia=fvia\n", | |
590 true, | |
591 "fvia", | |
592 }, | |
593 { "fingerprint occurs twice", | |
594 "HTTP/1.1 200 OK\n" | |
595 "Chrome-Proxy: bypass=2, fvia=fvia1, fvia=fvia2\n", | |
596 true, | |
597 "fvia1", | |
598 }, | |
599 }; | |
600 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | |
601 std::string headers(tests[i].headers); | |
602 HeadersToRaw(&headers); | |
603 scoped_refptr<net::HttpResponseHeaders> parsed( | |
604 new net::HttpResponseHeaders(headers)); | |
605 | |
606 std::string fingerprint; | |
607 bool fingerprint_exist = | |
608 GetDataReductionProxyActionFingerprintVia(parsed, &fingerprint); | |
609 EXPECT_EQ(tests[i].expected_fingerprint_exist, fingerprint_exist) | |
610 << tests[i].label; | |
611 | |
612 if (fingerprint_exist) | |
613 EXPECT_EQ(tests[i].expected_fingerprint, fingerprint) << tests[i].label; | |
614 } | |
615 } | |
616 | |
617 TEST_F(DataReductionProxyHeadersTest, | |
618 GetDataReductionProxyActionFingerprintOtherHeaders) { | |
619 const struct { | |
620 std::string label; | |
621 const char* headers; | |
622 bool expected_fingerprint_exist; | |
623 std::string expected_fingerprint; | |
624 } tests[] = { | |
625 { "fingerprint doesn't exist", | |
626 "HTTP/1.1 200 OK\n" | |
627 "Chrome-Proxy: bypass=0\n", | |
628 false, | |
629 "", | |
630 }, | |
631 { "fingerprint occurs once", | |
632 "HTTP/1.1 200 OK\n" | |
633 "Chrome-Proxy: bypass=1, foh=foh\n", | |
634 true, | |
635 "foh", | |
636 }, | |
637 { "fingerprint occurs twice", | |
638 "HTTP/1.1 200 OK\n" | |
639 "Chrome-Proxy: bypass=2, foh=foh1, foh=foh2\n", | |
640 true, | |
641 "foh1", | |
642 }, | |
643 }; | |
644 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | |
645 std::string headers(tests[i].headers); | |
646 HeadersToRaw(&headers); | |
647 scoped_refptr<net::HttpResponseHeaders> parsed( | |
648 new net::HttpResponseHeaders(headers)); | |
649 | |
650 std::string fingerprint; | |
651 bool fingerprint_exist = | |
652 GetDataReductionProxyActionFingerprintOtherHeaders( | |
653 parsed, &fingerprint); | |
654 EXPECT_EQ(tests[i].expected_fingerprint_exist, fingerprint_exist) | |
655 << tests[i].label; | |
656 | |
657 if (fingerprint_exist) | |
658 EXPECT_EQ(tests[i].expected_fingerprint, fingerprint) << tests[i].label; | |
659 } | |
660 } | |
661 | |
662 TEST_F(DataReductionProxyHeadersTest, | |
663 GetDataReductionProxyActionFingerprintContentLength) { | |
664 const struct { | |
665 std::string label; | |
666 const char* headers; | |
667 bool expected_fingerprint_exist; | |
668 std::string expected_fingerprint; | |
669 } tests[] = { | |
670 { "fingerprint doesn't exist", | |
671 "HTTP/1.1 200 OK\n" | |
672 "Chrome-Proxy: bypass=0\n", | |
673 false, | |
674 "", | |
675 }, | |
676 { "fingerprint occurs once", | |
677 "HTTP/1.1 200 OK\n" | |
678 "Chrome-Proxy: bypass=1, fcl=fcl\n", | |
679 true, | |
680 "fcl", | |
681 }, | |
682 { "fingerprint occurs twice", | |
683 "HTTP/1.1 200 OK\n" | |
684 "Chrome-Proxy: bypass=2, fcl=fcl1, fcl=fcl2\n", | |
685 true, | |
686 "fcl1", | |
687 }, | |
688 }; | |
689 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | |
690 std::string headers(tests[i].headers); | |
691 HeadersToRaw(&headers); | |
692 scoped_refptr<net::HttpResponseHeaders> parsed( | |
693 new net::HttpResponseHeaders(headers)); | |
694 | |
695 std::string fingerprint; | |
696 bool fingerprint_exist = | |
697 GetDataReductionProxyActionFingerprintContentLength( | |
698 parsed, &fingerprint); | |
699 EXPECT_EQ(tests[i].expected_fingerprint_exist, fingerprint_exist) | |
700 << tests[i].label; | |
701 | |
702 if (fingerprint_exist) | |
703 EXPECT_EQ(tests[i].expected_fingerprint, fingerprint) << tests[i].label; | |
704 } | |
705 } | |
706 | |
707 TEST_F(DataReductionProxyHeadersTest, | |
708 GetDataReductionProxyHeaderWithFingerprintRemoved) { | |
709 struct { | |
710 std::string label; | |
711 const char* headers; | |
712 std::string expected_output_values_string; | |
713 } test[] = { | |
714 { | |
715 "Checks the case that there is no Chrome-Proxy header's fingerprint.", | |
716 "HTTP/1.1 200 OK\n" | |
717 "Chrome-Proxy: 1,2,3,5\n", | |
718 "1,2,3,5,", | |
719 }, | |
720 { | |
721 "Checks the case that there is Chrome-Proxy header's fingerprint.", | |
722 "HTTP/1.1 200 OK\n" | |
723 "Chrome-Proxy: 1,2,3,fcp=4,5\n", | |
724 "1,2,3,5,", | |
725 }, | |
726 { | |
727 "Checks the case that there is Chrome-Proxy header's fingerprint, and it" | |
728 "occurs at the end.", | |
729 "HTTP/1.1 200 OK\n" | |
730 "Chrome-Proxy: 1,2,3,fcp=4,", | |
731 "1,2,3,", | |
732 }, | |
733 { | |
734 "Checks the case that there is Chrome-Proxy header's fingerprint, and it" | |
735 "occurs at the beginning.", | |
736 "HTTP/1.1 200 OK\n" | |
737 "Chrome-Proxy: fcp=1,2,3,", | |
738 "2,3,", | |
739 }, | |
740 }; | |
741 | |
742 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test); ++i) { | |
743 std::string headers(test[i].headers); | |
744 HeadersToRaw(&headers); | |
745 scoped_refptr<net::HttpResponseHeaders> parsed( | |
746 new net::HttpResponseHeaders(headers)); | |
747 | |
748 std::vector<std::string> output_values; | |
749 GetDataReductionProxyHeaderWithFingerprintRemoved(parsed, &output_values); | |
750 | |
751 std::string output_values_string; | |
752 for (size_t j = 0; j < output_values.size(); ++j) | |
753 output_values_string += output_values[j] + ","; | |
754 | |
755 EXPECT_EQ(test[i].expected_output_values_string, output_values_string) | |
756 << test[i].label; | |
757 } | |
758 } | |
759 | |
384 } // namespace data_reduction_proxy | 760 } // namespace data_reduction_proxy |
OLD | NEW |