Class (ProxyConfig)
Implements a ProxyConfig object to configure proxies.
NOTE
The initial APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version.
The initial APIs of this class are supported since API version 15.
The sample effect is subject to the actual device.
insertProxyRule15+
insertProxyRule(proxyRule: string, schemeFilter?: ProxySchemeFilter): void
Inserts a proxy rule for URLs matching schemeFilter. If schemeFilter is empty, all URLs use the specified proxy.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| proxyRule | string | Yes | The specified proxy. |
| schemeFilter | ProxySchemeFilter | No | Filter used to specify URLs that use the proxy. Default value: MATCH_ALL_SCHEMES. If undefined or null is passed, error code 401 will be thrown. |
Error codes
For details about the following error codes, see Universal Error Codes.
| Error Code | Error Message |
|---|---|
| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
Example
For details about the sample code, see removeProxyOverride.
insertDirectRule15+
insertDirectRule(schemeFilter?: ProxySchemeFilter): void
Inserts a proxy rule to specify that URLs matching schemeFilter are directly connected to the server.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| schemeFilter | ProxySchemeFilter | No | Filter used to specify URLs to be directly connected to the server. Default value: MATCH_ALL_SCHEMES. If undefined or null is passed, error code 401 will be thrown. |
Error codes
For details about the following error codes, see Universal Error Codes.
| Error Code | Error Message |
|---|---|
| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
Example
For details about the sample code, see removeProxyOverride.
insertBypassRule15+
insertBypassRule(bypassRule: string): void
Inserts a bypass rule to specify the URLs that should bypass the proxy and directly connect to the server.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| bypassRule | string | Yes | Bypass rule used to specify the URLs that should bypass the proxy. |
Error codes
For details about the following error codes, see Universal Error Codes.
| Error Code | Error Message |
|---|---|
| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
Example
For details about the sample code, see removeProxyOverride.
bypassHostnamesWithoutPeriod15+
bypassHostnamesWithoutPeriod(): void
Specifies that host names without a period should bypass the proxy and directly connect to the server.
System capability: SystemCapability.Web.Webview.Core
Example
For details about the sample code, see removeProxyOverride.
clearImplicitRules15+
clearImplicitRules(): void
Overrides the default behavior and forcibly sends the local host address or local IP address through the proxy. (By default, if host names are local IP addresses or local host addresses, they bypass the proxy.)
System capability: SystemCapability.Web.Webview.Core
Example
For details about the sample code, see removeProxyOverride.
enableReverseBypass15+
enableReverseBypass(reverse: boolean): void
Reverses the bypass rule.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| reverse | boolean | Yes | Whether to reverse the bypass rule. The default value is false, indicating the bypass rule set in insertBypassRule is not reversed. The value true indicates the opposite. |
Error codes
For details about the following error codes, see Universal Error Codes.
| Error Code | Error Message |
|---|---|
| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
Example
For details about the sample code, see removeProxyOverride.
getBypassRules15+
getBypassRules(): Array<string>
Obtains the list of URLs that do not use the proxy.
System capability: SystemCapability.Web.Webview.Core
Return value
| Type | Description |
|---|---|
| Array<string> | List of URLs that do not use the proxy. |
Example
For details about the sample code, see removeProxyOverride.
getProxyRules15+
getProxyRules(): Array<ProxyRule>
Obtains proxy rules.
System capability: SystemCapability.Web.Webview.Core
Return value
| Type | Description |
|---|---|
| Array<ProxyRule> | Proxy rules. |
Example
For details about the sample code, see removeProxyOverride.
isReverseBypassEnabled15+
isReverseBypassEnabled(): boolean
Obtains the value of enableReverseBypass. For details, see enableReverseBypass.
System capability: SystemCapability.Web.Webview.Core
Return value
| Type | Description |
|---|---|
| boolean | Value of enableReverseBypass. The default value is false, indicating the bypass rule set in insertBypassRule is not reversed. The value true indicates the opposite. |
Example
For details about the sample code, see removeProxyOverride.