ProxyConfig

public final class ProxyConfig
extends Object

java.lang.Object
   ↳ androidx.webkit.ProxyConfig


Config for ProxyController.setProxyOverride(ProxyConfig, Executor, Runnable).

Proxy rules should be added using addProxyRule methods. Multiple rules can be used as fallback if a proxy fails to respond (for example, the proxy server is down). Bypass rules can be set for URLs that should not use these settings.

For instance, the following code means that WebView would first try to use proxy1.com for all URLs, if that fails, proxy2.com, and if that fails, it would make a direct connection.

 ProxyConfig proxyConfig = new ProxyConfig.Builder().addProxyRule("proxy1.com")
                                                    .addProxyRule("proxy2.com")
                                                    .addDirect()
                                                    .build();
 

Summary

Nested classes

class ProxyConfig.Builder

ProxyConfig builder. 

class ProxyConfig.ProxyRule

Class that holds a scheme filter and a proxy URL. 

Constants

String MATCH_ALL_SCHEMES

Matches all schemes.

String MATCH_HTTP

HTTP scheme.

String MATCH_HTTPS

HTTPS scheme.

Public methods

List<String> getBypassRules()

Returns the current list that holds the bypass rules represented by this object.

List<ProxyConfig.ProxyRule> getProxyRules()

Returns the current list of proxy rules.

Inherited methods

Constants

MATCH_ALL_SCHEMES

public static final String MATCH_ALL_SCHEMES

Matches all schemes.

Constant Value: "*"

MATCH_HTTP

public static final String MATCH_HTTP

HTTP scheme.

Constant Value: "http"

MATCH_HTTPS

public static final String MATCH_HTTPS

HTTPS scheme.

Constant Value: "https"

Public methods

getBypassRules

public List<String> getBypassRules ()

Returns the current list that holds the bypass rules represented by this object.

To add new rules use ProxyConfig.Builder.addBypassRule(String).

Returns
List<String> List of bypass rules

getProxyRules

public List<ProxyConfig.ProxyRule> getProxyRules ()

Returns the current list of proxy rules. Each ProxyConfig.ProxyRule object holds the proxy URL and the URL schemes for which this proxy is used (one of MATCH_HTTP, MATCH_HTTPS, MATCH_ALL_SCHEMES).

To add new rules use ProxyConfig.Builder.addProxyRule(String) or ProxyConfig.Builder.addProxyRule(String, String).

Returns
List<ProxyConfig.ProxyRule> List of proxy rules