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 ignore_intermediary; | |
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_chrome_proxy_via_header, has_intermediary; |
274 HasDataReductionProxyViaHeader(parsed)); | 411 if (tests[i].ignore_intermediary) { |
412 has_chrome_proxy_via_header = | |
413 HasDataReductionProxyViaHeader(parsed, NULL); | |
414 } | |
415 else { | |
416 has_chrome_proxy_via_header = | |
417 HasDataReductionProxyViaHeader(parsed, &has_intermediary); | |
418 } | |
419 EXPECT_EQ(tests[i].expected_result, has_chrome_proxy_via_header); | |
420 if (has_chrome_proxy_via_header && !tests[i].ignore_intermediary) { | |
421 EXPECT_EQ(tests[i].expected_has_intermediary, has_intermediary); | |
422 } | |
275 } | 423 } |
276 } | 424 } |
277 | 425 |
278 TEST_F(DataReductionProxyHeadersTest, GetDataReductionProxyBypassEventType) { | 426 TEST_F(DataReductionProxyHeadersTest, GetDataReductionProxyBypassEventType) { |
279 const struct { | 427 const struct { |
280 const char* headers; | 428 const char* headers; |
281 net::ProxyService::DataReductionProxyBypassType expected_result; | 429 net::ProxyService::DataReductionProxyBypassType expected_result; |
282 } tests[] = { | 430 } tests[] = { |
283 { "HTTP/1.1 200 OK\n" | 431 { "HTTP/1.1 200 OK\n" |
284 "Chrome-Proxy: bypass=0\n" | 432 "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) { | 522 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
375 std::string headers(tests[i].headers); | 523 std::string headers(tests[i].headers); |
376 HeadersToRaw(&headers); | 524 HeadersToRaw(&headers); |
377 scoped_refptr<net::HttpResponseHeaders> parsed( | 525 scoped_refptr<net::HttpResponseHeaders> parsed( |
378 new net::HttpResponseHeaders(headers)); | 526 new net::HttpResponseHeaders(headers)); |
379 DataReductionProxyInfo chrome_proxy_info; | 527 DataReductionProxyInfo chrome_proxy_info; |
380 EXPECT_EQ(tests[i].expected_result, | 528 EXPECT_EQ(tests[i].expected_result, |
381 GetDataReductionProxyBypassType(parsed, &chrome_proxy_info)); | 529 GetDataReductionProxyBypassType(parsed, &chrome_proxy_info)); |
382 } | 530 } |
383 } | 531 } |
532 | |
533 TEST_F(DataReductionProxyHeadersTest, | |
534 GetDataReductionProxyActionFingerprintChromeProxy) { | |
535 const struct { | |
536 std::string label; | |
537 const char* headers; | |
538 bool expected_fingerprint_exist; | |
539 std::string expected_fingerprint; | |
540 } tests[] = { | |
541 { "fingerprint doesn't exist", | |
542 "HTTP/1.1 200 OK\n" | |
543 "Chrome-Proxy: bypass=0\n", | |
544 false, | |
545 "", | |
546 }, | |
547 { "fingerprint occurs once", | |
548 "HTTP/1.1 200 OK\n" | |
549 "Chrome-Proxy: bypass=1, fcp=fp\n", | |
550 true, | |
551 "fp", | |
552 }, | |
553 { "fingerprint occurs twice", | |
554 "HTTP/1.1 200 OK\n" | |
555 "Chrome-Proxy: bypass=2, fcp=fp1, fcp=fp2\n", | |
556 true, | |
557 "fp1", | |
558 }, | |
559 }; | |
560 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | |
561 std::string headers(tests[i].headers); | |
562 HeadersToRaw(&headers); | |
563 scoped_refptr<net::HttpResponseHeaders> parsed( | |
564 new net::HttpResponseHeaders(headers)); | |
565 | |
566 std::string fingerprint; | |
567 bool fingerprint_exist = GetDataReductionProxyActionFingerprintChromeProxy( | |
568 parsed, &fingerprint); | |
569 EXPECT_EQ(tests[i].expected_fingerprint_exist, fingerprint_exist) | |
570 << tests[i].label; | |
571 | |
572 if (fingerprint_exist) | |
573 EXPECT_EQ(tests[i].expected_fingerprint, fingerprint) << tests[i].label; | |
574 } | |
575 } | |
576 | |
577 TEST_F(DataReductionProxyHeadersTest, | |
578 GetDataReductionProxyActionFingerprintVia) { | |
579 const struct { | |
580 std::string label; | |
581 const char* headers; | |
582 bool expected_fingerprint_exist; | |
583 std::string expected_fingerprint; | |
584 } tests[] = { | |
585 { "fingerprint doesn't exist", | |
586 "HTTP/1.1 200 OK\n" | |
587 "Chrome-Proxy: bypass=0\n", | |
588 false, | |
589 "", | |
590 }, | |
591 { "fingerprint occurs once", | |
592 "HTTP/1.1 200 OK\n" | |
593 "Chrome-Proxy: bypass=1, fvia=fvia\n", | |
594 true, | |
595 "fvia", | |
596 }, | |
597 { "fingerprint occurs twice", | |
598 "HTTP/1.1 200 OK\n" | |
599 "Chrome-Proxy: bypass=2, fvia=fvia1, fvia=fvia2\n", | |
600 true, | |
601 "fvia1", | |
602 }, | |
603 }; | |
604 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | |
605 std::string headers(tests[i].headers); | |
606 HeadersToRaw(&headers); | |
607 scoped_refptr<net::HttpResponseHeaders> parsed( | |
608 new net::HttpResponseHeaders(headers)); | |
609 | |
610 std::string fingerprint; | |
611 bool fingerprint_exist = | |
612 GetDataReductionProxyActionFingerprintVia(parsed, &fingerprint); | |
613 EXPECT_EQ(tests[i].expected_fingerprint_exist, fingerprint_exist) | |
614 << tests[i].label; | |
615 | |
616 if (fingerprint_exist) | |
617 EXPECT_EQ(tests[i].expected_fingerprint, fingerprint) << tests[i].label; | |
618 } | |
619 } | |
620 | |
621 TEST_F(DataReductionProxyHeadersTest, | |
622 GetDataReductionProxyActionFingerprintOtherHeaders) { | |
623 const struct { | |
624 std::string label; | |
625 const char* headers; | |
626 bool expected_fingerprint_exist; | |
627 std::string expected_fingerprint; | |
628 } tests[] = { | |
629 { "fingerprint doesn't exist", | |
630 "HTTP/1.1 200 OK\n" | |
631 "Chrome-Proxy: bypass=0\n", | |
632 false, | |
633 "", | |
634 }, | |
635 { "fingerprint occurs once", | |
636 "HTTP/1.1 200 OK\n" | |
637 "Chrome-Proxy: bypass=1, foh=foh\n", | |
638 true, | |
639 "foh", | |
640 }, | |
641 { "fingerprint occurs twice", | |
642 "HTTP/1.1 200 OK\n" | |
643 "Chrome-Proxy: bypass=2, foh=foh1, foh=foh2\n", | |
644 true, | |
645 "foh1", | |
646 }, | |
647 }; | |
648 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | |
649 std::string headers(tests[i].headers); | |
650 HeadersToRaw(&headers); | |
651 scoped_refptr<net::HttpResponseHeaders> parsed( | |
652 new net::HttpResponseHeaders(headers)); | |
653 | |
654 std::string fingerprint; | |
655 bool fingerprint_exist = | |
656 GetDataReductionProxyActionFingerprintOtherHeaders( | |
657 parsed, &fingerprint); | |
658 EXPECT_EQ(tests[i].expected_fingerprint_exist, fingerprint_exist) | |
659 << tests[i].label; | |
660 | |
661 if (fingerprint_exist) | |
662 EXPECT_EQ(tests[i].expected_fingerprint, fingerprint) << tests[i].label; | |
663 } | |
664 } | |
665 | |
666 TEST_F(DataReductionProxyHeadersTest, | |
667 GetDataReductionProxyActionFingerprintContentLength) { | |
668 const struct { | |
669 std::string label; | |
670 const char* headers; | |
671 bool expected_fingerprint_exist; | |
672 std::string expected_fingerprint; | |
673 } tests[] = { | |
674 { "fingerprint doesn't exist", | |
675 "HTTP/1.1 200 OK\n" | |
676 "Chrome-Proxy: bypass=0\n", | |
677 false, | |
678 "", | |
679 }, | |
680 { "fingerprint occurs once", | |
681 "HTTP/1.1 200 OK\n" | |
682 "Chrome-Proxy: bypass=1, fcl=fcl\n", | |
683 true, | |
684 "fcl", | |
685 }, | |
686 { "fingerprint occurs twice", | |
687 "HTTP/1.1 200 OK\n" | |
688 "Chrome-Proxy: bypass=2, fcl=fcl1, fcl=fcl2\n", | |
689 true, | |
690 "fcl1", | |
691 }, | |
692 }; | |
693 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | |
694 std::string headers(tests[i].headers); | |
695 HeadersToRaw(&headers); | |
696 scoped_refptr<net::HttpResponseHeaders> parsed( | |
697 new net::HttpResponseHeaders(headers)); | |
698 | |
699 std::string fingerprint; | |
700 bool fingerprint_exist = | |
701 GetDataReductionProxyActionFingerprintContentLength( | |
702 parsed, &fingerprint); | |
703 EXPECT_EQ(tests[i].expected_fingerprint_exist, fingerprint_exist) | |
704 << tests[i].label; | |
705 | |
706 if (fingerprint_exist) | |
707 EXPECT_EQ(tests[i].expected_fingerprint, fingerprint) << tests[i].label; | |
708 } | |
709 } | |
710 | |
711 TEST_F(DataReductionProxyHeadersTest, | |
712 GetDataReductionProxyHeaderWithFingerprintRemoved) { | |
713 struct { | |
bengr
2014/08/06 17:26:19
Make this const.
xingx1
2014/08/06 17:35:21
Done.
| |
714 std::string label; | |
715 const char* headers; | |
716 std::string expected_output_values_string; | |
717 } test[] = { | |
718 { | |
719 "Checks the case that there is no Chrome-Proxy header's fingerprint.", | |
720 "HTTP/1.1 200 OK\n" | |
721 "Chrome-Proxy: 1,2,3,5\n", | |
722 "1,2,3,5,", | |
723 }, | |
724 { | |
725 "Checks the case that there is Chrome-Proxy header's fingerprint.", | |
726 "HTTP/1.1 200 OK\n" | |
727 "Chrome-Proxy: 1,2,3,fcp=4,5\n", | |
728 "1,2,3,5,", | |
729 }, | |
730 { | |
731 "Checks the case that there is Chrome-Proxy header's fingerprint, and it" | |
732 "occurs at the end.", | |
733 "HTTP/1.1 200 OK\n" | |
734 "Chrome-Proxy: 1,2,3,fcp=4,", | |
735 "1,2,3,", | |
736 }, | |
737 { | |
738 "Checks the case that there is Chrome-Proxy header's fingerprint, and it" | |
739 "occurs at the beginning.", | |
740 "HTTP/1.1 200 OK\n" | |
741 "Chrome-Proxy: fcp=1,2,3,", | |
742 "2,3,", | |
743 }, | |
744 }; | |
745 | |
746 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test); ++i) { | |
747 std::string headers(test[i].headers); | |
748 HeadersToRaw(&headers); | |
749 scoped_refptr<net::HttpResponseHeaders> parsed( | |
750 new net::HttpResponseHeaders(headers)); | |
751 | |
752 std::vector<std::string> output_values; | |
753 GetDataReductionProxyHeaderWithFingerprintRemoved(parsed, &output_values); | |
754 | |
755 std::string output_values_string; | |
756 for (size_t j = 0; j < output_values.size(); ++j) | |
757 output_values_string += output_values[j] + ","; | |
758 | |
759 EXPECT_EQ(test[i].expected_output_values_string, output_values_string) | |
760 << test[i].label; | |
761 } | |
762 } | |
763 | |
384 } // namespace data_reduction_proxy | 764 } // namespace data_reduction_proxy |
OLD | NEW |