| 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/browser/data_reduction_proxy_protocol.
h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.
h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } tests[] = { | 316 } tests[] = { |
| 317 { "HTTP/1.1 200 0K\n" | 317 { "HTTP/1.1 200 0K\n" |
| 318 "Chrome-Proxy: block=1\n" | 318 "Chrome-Proxy: block=1\n" |
| 319 "Via: 1.1 Chrome-Compression-Proxy\n", | 319 "Via: 1.1 Chrome-Compression-Proxy\n", |
| 320 | 320 |
| 321 "HTTP/1.1 302 Found\n" | 321 "HTTP/1.1 302 Found\n" |
| 322 "Chrome-Proxy: block=1\n" | 322 "Chrome-Proxy: block=1\n" |
| 323 "Via: 1.1 Chrome-Compression-Proxy\n" | 323 "Via: 1.1 Chrome-Compression-Proxy\n" |
| 324 "Location: http://www.google.com/\n" | 324 "Location: http://www.google.com/\n" |
| 325 }, | 325 }, |
| 326 { "HTTP/1.1 200 0K\n" |
| 327 "Chrome-Proxy: block-once\n" |
| 328 "Via: 1.1 Chrome-Compression-Proxy\n", |
| 329 |
| 330 "HTTP/1.1 302 Found\n" |
| 331 "Chrome-Proxy: block-once\n" |
| 332 "Via: 1.1 Chrome-Compression-Proxy\n" |
| 333 "Location: http://www.google.com/\n" |
| 334 }, |
| 326 { "HTTP/1.1 302 Found\n" | 335 { "HTTP/1.1 302 Found\n" |
| 327 "Location: http://foo.com/\n", | 336 "Location: http://foo.com/\n", |
| 328 | 337 |
| 329 "HTTP/1.1 302 Found\n" | 338 "HTTP/1.1 302 Found\n" |
| 330 "Location: http://www.google.com/\n" | 339 "Location: http://www.google.com/\n" |
| 331 }, | 340 }, |
| 332 }; | 341 }; |
| 333 | 342 |
| 334 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 343 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 335 std::string headers(tests[i].headers); | 344 std::string headers(tests[i].headers); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 { "GET", | 579 { "GET", |
| 571 "HTTP/1.1 200 OK\r\n" | 580 "HTTP/1.1 200 OK\r\n" |
| 572 "Server: proxy\r\n" | 581 "Server: proxy\r\n" |
| 573 "Chrome-Proxy: block=1\r\n" | 582 "Chrome-Proxy: block=1\r\n" |
| 574 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 583 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 575 true, | 584 true, |
| 576 2u, | 585 2u, |
| 577 true, | 586 true, |
| 578 1, | 587 1, |
| 579 BYPASS_EVENT_TYPE_SHORT | 588 BYPASS_EVENT_TYPE_SHORT |
| 580 } | 589 }, |
| 590 // Valid data reduction proxy response with a block-once message. It will be |
| 591 // retried, and there will be no proxies on the retry list since block-once |
| 592 // only affects the current request. |
| 593 { "GET", |
| 594 "HTTP/1.1 200 OK\r\n" |
| 595 "Server: proxy\r\n" |
| 596 "Chrome-Proxy: block-once\r\n" |
| 597 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 598 true, |
| 599 0u, |
| 600 true, |
| 601 0, |
| 602 BYPASS_EVENT_TYPE_CURRENT |
| 603 }, |
| 604 // Same as above with the OPTIONS method, which is idempotent. |
| 605 { "OPTIONS", |
| 606 "HTTP/1.1 200 OK\r\n" |
| 607 "Server: proxy\r\n" |
| 608 "Chrome-Proxy: block-once\r\n" |
| 609 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 610 true, |
| 611 0u, |
| 612 true, |
| 613 0, |
| 614 BYPASS_EVENT_TYPE_CURRENT |
| 615 }, |
| 616 // Same as above with the HEAD method, which is idempotent. |
| 617 { "HEAD", |
| 618 "HTTP/1.1 200 OK\r\n" |
| 619 "Server: proxy\r\n" |
| 620 "Chrome-Proxy: block-once\r\n" |
| 621 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 622 true, |
| 623 0u, |
| 624 false, |
| 625 0, |
| 626 BYPASS_EVENT_TYPE_CURRENT |
| 627 }, |
| 628 // Same as above with the PUT method, which is idempotent. |
| 629 { "PUT", |
| 630 "HTTP/1.1 200 OK\r\n" |
| 631 "Server: proxy\r\n" |
| 632 "Chrome-Proxy: block-once\r\n" |
| 633 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 634 true, |
| 635 0u, |
| 636 true, |
| 637 0, |
| 638 BYPASS_EVENT_TYPE_CURRENT |
| 639 }, |
| 640 // Same as above with the DELETE method, which is idempotent. |
| 641 { "DELETE", |
| 642 "HTTP/1.1 200 OK\r\n" |
| 643 "Server: proxy\r\n" |
| 644 "Chrome-Proxy: block-once\r\n" |
| 645 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 646 true, |
| 647 0u, |
| 648 true, |
| 649 0, |
| 650 BYPASS_EVENT_TYPE_CURRENT |
| 651 }, |
| 652 // Same as above with the TRACE method, which is idempotent. |
| 653 { "TRACE", |
| 654 "HTTP/1.1 200 OK\r\n" |
| 655 "Server: proxy\r\n" |
| 656 "Chrome-Proxy: block-once\r\n" |
| 657 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 658 true, |
| 659 0u, |
| 660 true, |
| 661 0, |
| 662 BYPASS_EVENT_TYPE_CURRENT |
| 663 }, |
| 664 // Valid data reduction proxy response with a block-once message. It will |
| 665 // not be retried because the request is non-idempotent, and there will be |
| 666 // no proxies on the retry list since block-once only affects the current |
| 667 // request. |
| 668 { "POST", |
| 669 "HTTP/1.1 200 OK\r\n" |
| 670 "Server: proxy\r\n" |
| 671 "Chrome-Proxy: block-once\r\n" |
| 672 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 673 false, |
| 674 0u, |
| 675 true, |
| 676 0, |
| 677 BYPASS_EVENT_TYPE_CURRENT |
| 678 }, |
| 679 // Valid data reduction proxy response with block and block-once messages. |
| 680 // The block message will override the block-once message, so both proxies |
| 681 // should be on the retry list when it completes. |
| 682 { "GET", |
| 683 "HTTP/1.1 200 OK\r\n" |
| 684 "Server: proxy\r\n" |
| 685 "Chrome-Proxy: block=1, block-once\r\n" |
| 686 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 687 true, |
| 688 2u, |
| 689 true, |
| 690 1, |
| 691 BYPASS_EVENT_TYPE_SHORT |
| 692 }, |
| 693 // Valid data reduction proxy response with bypass and block-once messages. |
| 694 // The bypass message will override the block-once message, so one proxy |
| 695 // should be on the retry list when it completes. |
| 696 { "GET", |
| 697 "HTTP/1.1 200 OK\r\n" |
| 698 "Server: proxy\r\n" |
| 699 "Chrome-Proxy: bypass=1, block-once\r\n" |
| 700 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 701 true, |
| 702 1u, |
| 703 true, |
| 704 1, |
| 705 BYPASS_EVENT_TYPE_SHORT |
| 706 }, |
| 581 }; | 707 }; |
| 582 std::string primary = proxy_params_->DefaultOrigin(); | 708 std::string primary = proxy_params_->DefaultOrigin(); |
| 583 std::string fallback = proxy_params_->DefaultFallbackOrigin(); | 709 std::string fallback = proxy_params_->DefaultFallbackOrigin(); |
| 584 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 710 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 585 DataReductionProxyBypassType bypass_type; | 711 DataReductionProxyBypassType bypass_type; |
| 586 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult( | 712 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult( |
| 587 "PROXY " + | 713 "PROXY " + |
| 588 HostPortPair::FromURL(GURL(primary)).ToString() + "; PROXY " + | 714 HostPortPair::FromURL(GURL(primary)).ToString() + "; PROXY " + |
| 589 HostPortPair::FromURL(GURL(fallback)).ToString() + "; DIRECT"), | 715 HostPortPair::FromURL(GURL(fallback)).ToString() + "; DIRECT"), |
| 590 &bypass_type); | 716 &bypass_type); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | 842 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; |
| 717 | 843 |
| 718 OnResolveProxyHandler(url, load_flags, &test_params, &info2); | 844 OnResolveProxyHandler(url, load_flags, &test_params, &info2); |
| 719 EXPECT_FALSE(info2.is_direct()); | 845 EXPECT_FALSE(info2.is_direct()); |
| 720 | 846 |
| 721 OnResolveProxyHandler(url, load_flags, &test_params, &info1); | 847 OnResolveProxyHandler(url, load_flags, &test_params, &info1); |
| 722 EXPECT_TRUE(info1.is_direct()); | 848 EXPECT_TRUE(info1.is_direct()); |
| 723 } | 849 } |
| 724 | 850 |
| 725 } // namespace data_reduction_proxy | 851 } // namespace data_reduction_proxy |
| OLD | NEW |