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