proxy_fallback.h 2.8 KB

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