ProxyConfig.Builder
public
static
final
class
ProxyConfig.Builder
extends Object
| java.lang.Object | |
| ↳ | androidx.webkit.ProxyConfig.Builder |
ProxyConfig builder. Use addProxyRule(String) or
addProxyRule(String, String) to add proxy rules. Use
addBypassRule(String) to add bypass rules. Use build() to
build this into a ProxyConfig object.
Note: applying a ProxyConfig with no rules will cause all
connections to be made directly.
Summary
Public constructors | |
|---|---|
Builder()
Create an empty ProxyConfig Builder. |
|
Builder(ProxyConfig proxyConfig)
Create a ProxyConfig Builder from an existing ProxyConfig object. |
|
Public methods | |
|---|---|
ProxyConfig.Builder
|
addBypassRule(String bypassRule)
Adds a new bypass rule that describes URLs that should skip proxy override settings and make a direct connection instead. |
ProxyConfig.Builder
|
addDirect(String schemeFilter)
Adds a proxy rule so URLs that match the scheme filter are connected to directly instead of using a proxy server. |
ProxyConfig.Builder
|
addDirect()
Adds a proxy rule so URLs are connected to directly instead of using a proxy server. |
ProxyConfig.Builder
|
addProxyRule(String proxyUrl)
Adds a proxy to be used for all URLs. |
ProxyConfig.Builder
|
addProxyRule(String proxyUrl, String schemeFilter)
This does everything that |
ProxyConfig
|
build()
Builds the current rules into a ProxyConfig object. |
ProxyConfig.Builder
|
bypassSimpleHostnames()
Hostnames without a period in them (and that are not IP literals) will skip proxy settings and be connected to directly instead. |
ProxyConfig.Builder
|
removeImplicitRules()
By default, certain hostnames implicitly bypass the proxy if they are link-local IPs, or localhost addresses. |
Inherited methods | |
|---|---|
Public constructors
Builder
public Builder ()
Create an empty ProxyConfig Builder.
Builder
public Builder (ProxyConfig proxyConfig)
Create a ProxyConfig Builder from an existing ProxyConfig object.
| Parameters | |
|---|---|
proxyConfig |
ProxyConfig |
Public methods
addBypassRule
public ProxyConfig.Builder addBypassRule (String bypassRule)
Adds a new bypass rule that describes URLs that should skip proxy override settings
and make a direct connection instead. These can be URLs or IP addresses. Wildcards are
accepted. For instance, the rule "*example.com" would mean that requests to
"http://example.com" and "www.example.com" would not be directed to any
proxy, instead, would be made directly to the origin specified by the URL.
| Parameters | |
|---|---|
bypassRule |
String: Rule to be added to the exclusion list |
| Returns | |
|---|---|
ProxyConfig.Builder |
This Builder object |
addDirect
public ProxyConfig.Builder addDirect (String schemeFilter)
Adds a proxy rule so URLs that match the scheme filter are connected to directly instead of using a proxy server.
| Parameters | |
|---|---|
schemeFilter |
String: Scheme filter |
| Returns | |
|---|---|
ProxyConfig.Builder |
This Builder object |
addDirect
public ProxyConfig.Builder addDirect ()
Adds a proxy rule so URLs are connected to directly instead of using a proxy server.
| Returns | |
|---|---|
ProxyConfig.Builder |
This Builder object |
addProxyRule
public ProxyConfig.Builder addProxyRule (String proxyUrl)
Adds a proxy to be used for all URLs. This method can be called multiple times to add multiple rules. Additional rules have decreasing precedence.
Proxy is a string in the format [scheme://]host[:port]. Scheme is optional, if
present must be HTTP, HTTPS or
SOCKS and defaults to HTTP.
Host is one of an IPv6 literal with brackets, an IPv4 literal or one or more labels
separated by a period. Port number is optional and defaults to 80 for
HTTP, 443 for HTTPS and 1080 for SOCKS.
The correct syntax for hosts is defined by RFC 3986
Examples:
| Scheme | Host | Port | Proxy URL |
|---|---|---|---|
| example.com | example.com | ||
| https | example.com | https://example.com | |
| example.com | 1111 | example.com:1111 | |
| https | example.com | 1111 | https://example.com:1111 |
| 192.168.1.1 | 192.168.1.1 | ||
| 192.168.1.1 | 2020 | 192.168.1.1:2020 | |
| [10:20:30:40:50:60:70:80] | [10:20:30:40:50:60:70:80] |
| Parameters | |
|---|---|
proxyUrl |
String: Proxy URL |
| Returns | |
|---|---|
ProxyConfig.Builder |
This Builder object |
addProxyRule
public ProxyConfig.Builder addProxyRule (String proxyUrl, String schemeFilter)
This does everything that addProxyRule(String) does,
but only applies to URLs using schemeFilter. Scheme filter must be one of
ProxyConfig.MATCH_HTTP, ProxyConfig.MATCH_HTTPS or
ProxyConfig.MATCH_ALL_SCHEMES.
| Parameters | |
|---|---|
proxyUrl |
String: Proxy URL |
schemeFilter |
String: Scheme filter |
| Returns | |
|---|---|
ProxyConfig.Builder |
This Builder object |
build
public ProxyConfig build ()
Builds the current rules into a ProxyConfig object.
| Returns | |
|---|---|
ProxyConfig |
The ProxyConfig object represented by this Builder |
bypassSimpleHostnames
public ProxyConfig.Builder bypassSimpleHostnames ()
Hostnames without a period in them (and that are not IP literals) will skip proxy
settings and be connected to directly instead. Examples: "abc", "local",
"some-domain".
Hostnames with a trailing dot are not considered simple by this definition.
| Returns | |
|---|---|
ProxyConfig.Builder |
This Builder object |
removeImplicitRules
public ProxyConfig.Builder removeImplicitRules ()
By default, certain hostnames implicitly bypass the proxy if they are link-local IPs, or localhost addresses. For instance hostnames matching any of (non-exhaustive list):
- localhost
- *.localhost
- [::1]
- 127.0.0.1/8
- 169.254/16
- [FE80::]/10
Call this function to override the default behavior and force localhost and link-local URLs to be sent through the proxy.
| Returns | |
|---|---|
ProxyConfig.Builder |
This Builder object |