OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/http/http_network_layer.h" | 5 #include "net/http/http_network_layer.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "net/base/net_log.h" | 9 #include "net/base/net_log.h" |
10 #include "net/cert/mock_cert_verifier.h" | 10 #include "net/cert/mock_cert_verifier.h" |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 // Verify that a Chrome-Proxy: bypass=<seconds> header induces proxy | 616 // Verify that a Chrome-Proxy: bypass=<seconds> header induces proxy |
617 // fallback to a second proxy, if configured. | 617 // fallback to a second proxy, if configured. |
618 std::string bad_proxy = GetChromeProxy(); | 618 std::string bad_proxy = GetChromeProxy(); |
619 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult( | 619 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult( |
620 "PROXY " + bad_proxy + "; PROXY good:8080")); | 620 "PROXY " + bad_proxy + "; PROXY good:8080")); |
621 | 621 |
622 MockRead data_reads[] = { | 622 MockRead data_reads[] = { |
623 MockRead("HTTP/1.1 200 OK\r\n" | 623 MockRead("HTTP/1.1 200 OK\r\n" |
624 "Connection: keep-alive\r\n" | 624 "Connection: keep-alive\r\n" |
625 "Chrome-Proxy: bypass=86400\r\n" | 625 "Chrome-Proxy: bypass=86400\r\n" |
626 "Via: 1.1 Chrome Compression Proxy\r\n\r\n"), | 626 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n"), |
627 MockRead("Bypass message"), | 627 MockRead("Bypass message"), |
628 MockRead(SYNCHRONOUS, OK), | 628 MockRead(SYNCHRONOUS, OK), |
629 }; | 629 }; |
630 | 630 |
631 TestProxyFallbackWithMockReads(bad_proxy, "", data_reads, | 631 TestProxyFallbackWithMockReads(bad_proxy, "", data_reads, |
632 arraysize(data_reads), 1u); | 632 arraysize(data_reads), 1u); |
633 EXPECT_EQ(base::TimeDelta::FromSeconds(86400), | 633 EXPECT_EQ(base::TimeDelta::FromSeconds(86400), |
634 (*proxy_service_->proxy_retry_info().begin()).second.current_delay); | 634 (*proxy_service_->proxy_retry_info().begin()).second.current_delay); |
635 } | 635 } |
636 | 636 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 TEST_F(HttpNetworkLayerTest, NoServerFallbackWithChainedViaHeader) { | 674 TEST_F(HttpNetworkLayerTest, NoServerFallbackWithChainedViaHeader) { |
675 // Verify that Chrome will not be induced to bypass the Chrome proxy when | 675 // Verify that Chrome will not be induced to bypass the Chrome proxy when |
676 // the Chrome Proxy via header is present, even if that header is chained. | 676 // the Chrome Proxy via header is present, even if that header is chained. |
677 std::string chrome_proxy = GetChromeProxy(); | 677 std::string chrome_proxy = GetChromeProxy(); |
678 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult( | 678 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult( |
679 "PROXY " + chrome_proxy + "; PROXY good:8080")); | 679 "PROXY " + chrome_proxy + "; PROXY good:8080")); |
680 | 680 |
681 MockRead data_reads[] = { | 681 MockRead data_reads[] = { |
682 MockRead("HTTP/1.1 200 OK\r\n" | 682 MockRead("HTTP/1.1 200 OK\r\n" |
683 "Connection: keep-alive\r\n" | 683 "Connection: keep-alive\r\n" |
684 "Via: 1.1 Chrome Compression Proxy, 1.0 some-other-proxy\r\n\r\n"), | 684 "Via: 1.1 Chrome-Compression-Proxy, 1.0 some-other-proxy\r\n\r\n"), |
685 MockRead("Bypass message"), | 685 MockRead("Bypass message"), |
686 MockRead(SYNCHRONOUS, OK), | 686 MockRead(SYNCHRONOUS, OK), |
687 }; | 687 }; |
| 688 |
| 689 TestProxyFallbackByMethodWithMockReads(chrome_proxy, std::string(), |
| 690 data_reads, arraysize(data_reads), |
| 691 "GET", std::string(), false, 0); |
| 692 } |
| 693 |
| 694 TEST_F(HttpNetworkLayerTest, NoServerFallbackWithDeprecatedViaHeader) { |
| 695 // Verify that Chrome will not be induced to bypass the Chrome proxy when |
| 696 // the Chrome Proxy via header is present, even if that header is chained. |
| 697 std::string chrome_proxy = GetChromeProxy(); |
| 698 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult( |
| 699 "PROXY " + chrome_proxy + "; PROXY good:8080")); |
| 700 |
| 701 MockRead data_reads[] = { |
| 702 MockRead("HTTP/1.1 200 OK\r\n" |
| 703 "Connection: keep-alive\r\n" |
| 704 "Via: 1.1 Chrome Compression Proxy\r\n\r\n"), |
| 705 MockRead("Bypass message"), |
| 706 MockRead(SYNCHRONOUS, OK), |
| 707 }; |
688 | 708 |
689 TestProxyFallbackByMethodWithMockReads(chrome_proxy, std::string(), | 709 TestProxyFallbackByMethodWithMockReads(chrome_proxy, std::string(), |
690 data_reads, arraysize(data_reads), | 710 data_reads, arraysize(data_reads), |
691 "GET", std::string(), false, 0); | 711 "GET", std::string(), false, 0); |
692 } | 712 } |
693 | 713 |
694 #if defined(DATA_REDUCTION_FALLBACK_HOST) | 714 #if defined(DATA_REDUCTION_FALLBACK_HOST) |
695 TEST_F(HttpNetworkLayerTest, ServerFallbackWithProxyTimedBypassAll) { | 715 TEST_F(HttpNetworkLayerTest, ServerFallbackWithProxyTimedBypassAll) { |
696 // Verify that a Chrome-Proxy: block=<seconds> header bypasses a | 716 // Verify that a Chrome-Proxy: block=<seconds> header bypasses a |
697 // a configured Chrome-Proxy and fallback and induces proxy fallback to a | 717 // a configured Chrome-Proxy and fallback and induces proxy fallback to a |
698 // third proxy, if configured. | 718 // third proxy, if configured. |
699 std::string bad_proxy = GetChromeProxy(); | 719 std::string bad_proxy = GetChromeProxy(); |
700 std::string fallback_proxy = GetChromeFallbackProxy(); | 720 std::string fallback_proxy = GetChromeFallbackProxy(); |
701 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult( | 721 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult( |
702 "PROXY " + bad_proxy + "; PROXY " + fallback_proxy + | 722 "PROXY " + bad_proxy + "; PROXY " + fallback_proxy + |
703 "; PROXY good:8080")); | 723 "; PROXY good:8080")); |
704 | 724 |
705 MockRead data_reads[] = { | 725 MockRead data_reads[] = { |
706 MockRead("HTTP/1.1 200 OK\r\n" | 726 MockRead("HTTP/1.1 200 OK\r\n" |
707 "Connection: keep-alive\r\n" | 727 "Connection: keep-alive\r\n" |
708 "Chrome-Proxy: block=86400\r\n" | 728 "Chrome-Proxy: block=86400\r\n" |
709 "Via: 1.1 Chrome Compression Proxy\r\n\r\n"), | 729 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n"), |
710 MockRead("Bypass message"), | 730 MockRead("Bypass message"), |
711 MockRead(SYNCHRONOUS, OK), | 731 MockRead(SYNCHRONOUS, OK), |
712 }; | 732 }; |
713 | 733 |
714 TestProxyFallbackWithMockReads(bad_proxy, fallback_proxy, data_reads, | 734 TestProxyFallbackWithMockReads(bad_proxy, fallback_proxy, data_reads, |
715 arraysize(data_reads), 2u); | 735 arraysize(data_reads), 2u); |
716 EXPECT_EQ(base::TimeDelta::FromSeconds(86400), | 736 EXPECT_EQ(base::TimeDelta::FromSeconds(86400), |
717 (*proxy_service_->proxy_retry_info().begin()).second.current_delay); | 737 (*proxy_service_->proxy_retry_info().begin()).second.current_delay); |
718 } | 738 } |
719 #endif // defined(DATA_REDUCTION_FALLBACK_HOST) | 739 #endif // defined(DATA_REDUCTION_FALLBACK_HOST) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 ASSERT_EQ(ERR_CONNECTION_RESET, callback.GetResult(rv)); | 805 ASSERT_EQ(ERR_CONNECTION_RESET, callback.GetResult(rv)); |
786 | 806 |
787 // If the response info is null, that means that any consumer won't | 807 // If the response info is null, that means that any consumer won't |
788 // see the network accessed bit set. | 808 // see the network accessed bit set. |
789 EXPECT_EQ(NULL, trans->GetResponseInfo()); | 809 EXPECT_EQ(NULL, trans->GetResponseInfo()); |
790 } | 810 } |
791 | 811 |
792 } // namespace | 812 } // namespace |
793 | 813 |
794 } // namespace net | 814 } // namespace net |
OLD | NEW |