1*6777b538SAndroid Build Coastguard Worker // Copyright 2018 The Chromium Authors 2*6777b538SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*6777b538SAndroid Build Coastguard Worker // found in the LICENSE file. 4*6777b538SAndroid Build Coastguard Worker 5*6777b538SAndroid Build Coastguard Worker #ifndef NET_HTTP_PROXY_FALLBACK_H_ 6*6777b538SAndroid Build Coastguard Worker #define NET_HTTP_PROXY_FALLBACK_H_ 7*6777b538SAndroid Build Coastguard Worker 8*6777b538SAndroid Build Coastguard Worker // ------------------------------------------------------------ 9*6777b538SAndroid Build Coastguard Worker // Proxy Fallback Overview 10*6777b538SAndroid Build Coastguard Worker // ------------------------------------------------------------ 11*6777b538SAndroid Build Coastguard Worker // 12*6777b538SAndroid Build Coastguard Worker // Proxy fallback is a feature that is split between the proxy resolution layer 13*6777b538SAndroid Build Coastguard Worker // and the HTTP layers. 14*6777b538SAndroid Build Coastguard Worker // 15*6777b538SAndroid Build Coastguard Worker // The proxy resolution layer is responsible for: 16*6777b538SAndroid Build Coastguard Worker // * Obtaining a list of proxies to use 17*6777b538SAndroid Build Coastguard Worker // (ProxyResolutionService::ResolveProxy). Proxy lists are (usually) the 18*6777b538SAndroid Build Coastguard Worker // result of having evaluated a PAC script, such as: 19*6777b538SAndroid Build Coastguard Worker // return "PROXY foobar1:8080; HTTPS foobar2:8080; DIRECT"; 20*6777b538SAndroid Build Coastguard Worker // 21*6777b538SAndroid Build Coastguard Worker // * Re-ordering the proxy list such that proxy chains that have recently 22*6777b538SAndroid Build Coastguard Worker // failed are given lower priority (ProxyInfo::DeprioritizeBadProxyChains) 23*6777b538SAndroid Build Coastguard Worker // 24*6777b538SAndroid Build Coastguard Worker // * Maintaining the expiring cache of proxy chains that have recently failed. 25*6777b538SAndroid Build Coastguard Worker // 26*6777b538SAndroid Build Coastguard Worker // 27*6777b538SAndroid Build Coastguard Worker // The HTTP layer is responsible for: 28*6777b538SAndroid Build Coastguard Worker // * Attempting to issue the URLRequest through each of the 29*6777b538SAndroid Build Coastguard Worker // proxy chains, in the order specified by the list. 30*6777b538SAndroid Build Coastguard Worker // 31*6777b538SAndroid Build Coastguard Worker // * Deciding whether this attempt was successful, whether it was a failure 32*6777b538SAndroid Build Coastguard Worker // but should keep trying other proxy chains, or whether it was a failure 33*6777b538SAndroid Build Coastguard Worker // and should stop trying other proxy chains. 34*6777b538SAndroid Build Coastguard Worker // 35*6777b538SAndroid Build Coastguard Worker // * Upon successful completion of an attempt though a proxy chain, calling 36*6777b538SAndroid Build Coastguard Worker // ProxyResolutionService::ReportSuccess to inform it of all the failed 37*6777b538SAndroid Build Coastguard Worker // attempts that were made. (A proxy chain is only considered to be "bad" 38*6777b538SAndroid Build Coastguard Worker // if the request was able to be completed through some other proxy chain). 39*6777b538SAndroid Build Coastguard Worker // 40*6777b538SAndroid Build Coastguard Worker // 41*6777b538SAndroid Build Coastguard Worker // Exactly how to interpret the proxy lists returned by PAC is not specified by 42*6777b538SAndroid Build Coastguard Worker // a standard. The justifications for what errors are considered for fallback 43*6777b538SAndroid Build Coastguard Worker // are given beside the implementation. 44*6777b538SAndroid Build Coastguard Worker 45*6777b538SAndroid Build Coastguard Worker #include "net/base/net_export.h" 46*6777b538SAndroid Build Coastguard Worker 47*6777b538SAndroid Build Coastguard Worker namespace net { 48*6777b538SAndroid Build Coastguard Worker 49*6777b538SAndroid Build Coastguard Worker class ProxyChain; 50*6777b538SAndroid Build Coastguard Worker 51*6777b538SAndroid Build Coastguard Worker // Returns true if a failed request issued through a proxy chain should be 52*6777b538SAndroid Build Coastguard Worker // re-tried using the next proxy chain in the fallback list. 53*6777b538SAndroid Build Coastguard Worker // 54*6777b538SAndroid Build Coastguard Worker // The proxy fallback logic is a compromise between compatibility and 55*6777b538SAndroid Build Coastguard Worker // increasing odds of success, and may choose not to retry a request on the 56*6777b538SAndroid Build Coastguard Worker // next proxy option, even though that could work. 57*6777b538SAndroid Build Coastguard Worker // 58*6777b538SAndroid Build Coastguard Worker // - `proxy_chain` is the proxy chain that failed the request. 59*6777b538SAndroid Build Coastguard Worker // - `error` is the error for the request when it was sent through 60*6777b538SAndroid Build Coastguard Worker // `proxy_chain`. 61*6777b538SAndroid Build Coastguard Worker // - `final_error` is an out parameter that is set with the "final" error to 62*6777b538SAndroid Build Coastguard Worker // report to the caller. The error is only re-written in cases where 63*6777b538SAndroid Build Coastguard Worker // CanFalloverToNextProxy() returns false. 64*6777b538SAndroid Build Coastguard Worker // - `is_for_ip_protection` is true if this request is to an IP Protection 65*6777b538SAndroid Build Coastguard Worker // proxy. 66*6777b538SAndroid Build Coastguard Worker NET_EXPORT bool CanFalloverToNextProxy(const ProxyChain& proxy_chain, 67*6777b538SAndroid Build Coastguard Worker int error, 68*6777b538SAndroid Build Coastguard Worker int* final_error, 69*6777b538SAndroid Build Coastguard Worker bool is_for_ip_protection = false); 70*6777b538SAndroid Build Coastguard Worker 71*6777b538SAndroid Build Coastguard Worker } // namespace net 72*6777b538SAndroid Build Coastguard Worker 73*6777b538SAndroid Build Coastguard Worker #endif // NET_HTTP_PROXY_FALLBACK_H_ 74