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

Side by Side Diff: net/http/http_network_layer_unittest.cc

Issue 156373002: Support for new data reduction proxy via header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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
OLDNEW
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
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
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"),
685 MockRead("Bypass message"),
686 MockRead(SYNCHRONOUS, OK),
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 };
708
709 TestProxyFallbackByMethodWithMockReads(chrome_proxy, std::string(),
710 data_reads, arraysize(data_reads),
711 "GET", std::string(), false, 0);
712 }
713
714 TEST_F(HttpNetworkLayerTest, ServerFallbackWithNoViaHeader) {
715 // Verify that the lack of a Via header induces proxy fallback to a second
716 // proxy, if configured.
717 std::string chrome_proxy = GetChromeProxy();
718 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult(
719 "PROXY " + chrome_proxy + "; PROXY good:8080"));
720
721 MockRead data_reads[] = {
722 MockRead("HTTP/1.1 200 OK\r\n"
723 "Connection: keep-alive\r\n\r\n"),
724 MockRead("Bypass message"),
725 MockRead(SYNCHRONOUS, OK),
726 };
727
728 TestProxyFallbackWithMockReads(chrome_proxy, std::string(), data_reads,
729 arraysize(data_reads), 1u);
730 }
731
732 TEST_F(HttpNetworkLayerTest, NoServerFallbackWithChainedViaHeader) {
733 // Verify that Chrome will not be induced to bypass the Chrome proxy when
734 // the Chrome Proxy via header is present, even if that header is chained.
735 std::string chrome_proxy = GetChromeProxy();
736 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult(
737 "PROXY " + chrome_proxy + "; PROXY good:8080"));
738
739 MockRead data_reads[] = {
740 MockRead("HTTP/1.1 200 OK\r\n"
741 "Connection: keep-alive\r\n"
684 "Via: 1.1 Chrome Compression Proxy, 1.0 some-other-proxy\r\n\r\n"), 742 "Via: 1.1 Chrome Compression Proxy, 1.0 some-other-proxy\r\n\r\n"),
685 MockRead("Bypass message"), 743 MockRead("Bypass message"),
686 MockRead(SYNCHRONOUS, OK), 744 MockRead(SYNCHRONOUS, OK),
687 }; 745 };
688 746
689 TestProxyFallbackByMethodWithMockReads(chrome_proxy, std::string(), 747 TestProxyFallbackByMethodWithMockReads(chrome_proxy, std::string(),
690 data_reads, arraysize(data_reads), 748 data_reads, arraysize(data_reads),
691 "GET", std::string(), false, 0); 749 "GET", std::string(), false, 0);
692 } 750 }
693 751
694 #if defined(DATA_REDUCTION_FALLBACK_HOST) 752 #if defined(DATA_REDUCTION_FALLBACK_HOST)
695 TEST_F(HttpNetworkLayerTest, ServerFallbackWithProxyTimedBypassAll) { 753 TEST_F(HttpNetworkLayerTest, ServerFallbackWithProxyTimedBypassAll) {
696 // Verify that a Chrome-Proxy: block=<seconds> header bypasses a 754 // Verify that a Chrome-Proxy: block=<seconds> header bypasses a
697 // a configured Chrome-Proxy and fallback and induces proxy fallback to a 755 // a configured Chrome-Proxy and fallback and induces proxy fallback to a
698 // third proxy, if configured. 756 // third proxy, if configured.
699 std::string bad_proxy = GetChromeProxy(); 757 std::string bad_proxy = GetChromeProxy();
700 std::string fallback_proxy = GetChromeFallbackProxy(); 758 std::string fallback_proxy = GetChromeFallbackProxy();
701 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult( 759 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult(
702 "PROXY " + bad_proxy + "; PROXY " + fallback_proxy + 760 "PROXY " + bad_proxy + "; PROXY " + fallback_proxy +
703 "; PROXY good:8080")); 761 "; PROXY good:8080"));
704 762
705 MockRead data_reads[] = { 763 MockRead data_reads[] = {
706 MockRead("HTTP/1.1 200 OK\r\n" 764 MockRead("HTTP/1.1 200 OK\r\n"
707 "Connection: keep-alive\r\n" 765 "Connection: keep-alive\r\n"
708 "Chrome-Proxy: block=86400\r\n" 766 "Chrome-Proxy: block=86400\r\n"
709 "Via: 1.1 Chrome Compression Proxy\r\n\r\n"), 767 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n"),
710 MockRead("Bypass message"), 768 MockRead("Bypass message"),
711 MockRead(SYNCHRONOUS, OK), 769 MockRead(SYNCHRONOUS, OK),
712 }; 770 };
713 771
714 TestProxyFallbackWithMockReads(bad_proxy, fallback_proxy, data_reads, 772 TestProxyFallbackWithMockReads(bad_proxy, fallback_proxy, data_reads,
715 arraysize(data_reads), 2u); 773 arraysize(data_reads), 2u);
716 EXPECT_EQ(base::TimeDelta::FromSeconds(86400), 774 EXPECT_EQ(base::TimeDelta::FromSeconds(86400),
717 (*proxy_service_->proxy_retry_info().begin()).second.current_delay); 775 (*proxy_service_->proxy_retry_info().begin()).second.current_delay);
718 } 776 }
719 #endif // defined(DATA_REDUCTION_FALLBACK_HOST) 777 #endif // defined(DATA_REDUCTION_FALLBACK_HOST)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 ASSERT_EQ(ERR_CONNECTION_RESET, callback.GetResult(rv)); 843 ASSERT_EQ(ERR_CONNECTION_RESET, callback.GetResult(rv));
786 844
787 // If the response info is null, that means that any consumer won't 845 // If the response info is null, that means that any consumer won't
788 // see the network accessed bit set. 846 // see the network accessed bit set.
789 EXPECT_EQ(NULL, trans->GetResponseInfo()); 847 EXPECT_EQ(NULL, trans->GetResponseInfo());
790 } 848 }
791 849
792 } // namespace 850 } // namespace
793 851
794 } // namespace net 852 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698