• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Class (ProxyConfig)
2
3Implements a **ProxyConfig** object to configure proxies.
4
5> **NOTE**
6>
7> - 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.
8>
9> - The initial APIs of this class are supported since API version 15.
10>
11> - You can preview how this component looks on a real device, but not in DevEco Studio Previewer.
12
13## insertProxyRule<sup>15+</sup>
14
15insertProxyRule(proxyRule: string, schemeFilter?: ProxySchemeFilter): void
16
17Inserts a proxy rule for URLs matching **schemeFilter**. If **schemeFilter** is empty, all URLs use the specified proxy.
18
19**System capability**: SystemCapability.Web.Webview.Core
20
21**Parameters**
22
23| Name         | Type    |  Mandatory | Description          |
24| ---------------| ------- | ---- | ------------- |
25| proxyRule      | string  | Yes  | The specified proxy.|
26| schemeFilter   | [ProxySchemeFilter](./arkts-apis-webview-e.md#proxyschemefilter15)  | No  | Filter used to specify URLs that use the proxy.<br>Default value: **MATCH_ALL_SCHEMES**.|
27
28**Error codes**
29
30For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md).
31
32| Error Code| Error Message                             |
33| -------- | ------------------------------------- |
34|  401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.  |
35
36**Example**
37
38For details about the sample code, see [removeProxyOverride](./arkts-apis-webview-ProxyController.md#removeproxyoverride15).
39
40## insertDirectRule<sup>15+</sup>
41
42insertDirectRule(schemeFilter?: ProxySchemeFilter): void
43
44Inserts a proxy rule to specify that URLs matching **schemeFilter** are directly connected to the server.
45
46**System capability**: SystemCapability.Web.Webview.Core
47
48**Parameters**
49
50| Name         | Type    |  Mandatory | Description          |
51| ---------------| ------- | ---- | ------------- |
52| schemeFilter   | [ProxySchemeFilter](./arkts-apis-webview-e.md#proxyschemefilter15)  | No  | Filter used to specify URLs to be directly connected to the server.<br>Default value: **MATCH_ALL_SCHEMES**.|
53
54**Error codes**
55
56For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md).
57
58| Error Code| Error Message                             |
59| -------- | ------------------------------------- |
60|  401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.  |
61
62**Example**
63
64For details about the sample code, see [removeProxyOverride](./arkts-apis-webview-ProxyController.md#removeproxyoverride15).
65
66## insertBypassRule<sup>15+</sup>
67
68insertBypassRule(bypassRule: string): void
69
70Inserts a bypass rule to specify the URLs that should bypass the proxy and directly connect to the server.
71
72**System capability**: SystemCapability.Web.Webview.Core
73
74**Parameters**
75
76| Name         | Type    |  Mandatory | Description          |
77| ---------------| ------- | ---- | ------------- |
78| bypassRule     | string  | Yes  | Bypass rule used to specify the URLs that should bypass the proxy.|
79
80**Error codes**
81
82For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md).
83
84| Error Code| Error Message                             |
85| -------- | ------------------------------------- |
86|  401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
87
88**Example**
89
90For details about the sample code, see [removeProxyOverride](./arkts-apis-webview-ProxyController.md#removeproxyoverride15).
91
92## bypassHostnamesWithoutPeriod<sup>15+</sup>
93
94bypassHostnamesWithoutPeriod(): void
95
96Specifies that host names without a period should bypass the proxy and directly connect to the server.
97
98**System capability**: SystemCapability.Web.Webview.Core
99
100**Example**
101
102For details about the sample code, see [removeProxyOverride](./arkts-apis-webview-ProxyController.md#removeproxyoverride15).
103
104## clearImplicitRules<sup>15+</sup>
105
106clearImplicitRules(): void
107
108Overrides 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.)
109
110**System capability**: SystemCapability.Web.Webview.Core
111
112**Example**
113
114For details about the sample code, see [removeProxyOverride](./arkts-apis-webview-ProxyController.md#removeproxyoverride15).
115
116## enableReverseBypass<sup>15+</sup>
117
118enableReverseBypass(reverse: boolean): void
119
120Reverses the bypass rule.
121
122**System capability**: SystemCapability.Web.Webview.Core
123
124**Parameters**
125
126| Name         | Type    |  Mandatory | Description          |
127| ---------------| ------- | ---- | ------------- |
128| reverse     | boolean  | Yes  | Whether to reverse the bypass rule. The default value is **false**, indicating the bypass rule set in [insertBypassRule](#insertbypassrule15) is not reversed. The value **true** indicates the opposite.|
129
130**Error codes**
131
132For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md).
133
134| Error Code| Error Message                             |
135| -------- | ------------------------------------- |
136|  401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.  |
137
138**Example**
139
140For details about the sample code, see [removeProxyOverride](./arkts-apis-webview-ProxyController.md#removeproxyoverride15).
141
142## getBypassRules<sup>15+</sup>
143
144getBypassRules(): Array\<string\>
145
146Obtains the list of URLs that do not use the proxy.
147
148**System capability**: SystemCapability.Web.Webview.Core
149
150**Return value**
151
152| Type  | Description                     |
153| ------ | ------------------------- |
154| Array\<string\> | List of URLs that do not use the proxy.|
155
156**Example**
157
158For details about the sample code, see [removeProxyOverride](./arkts-apis-webview-ProxyController.md#removeproxyoverride15).
159
160## getProxyRules<sup>15+</sup>
161
162getProxyRules(): Array\<ProxyRule\>
163
164Obtains proxy rules.
165
166**System capability**: SystemCapability.Web.Webview.Core
167
168**Return value**
169
170| Type  | Description                     |
171| ------ | ------------------------- |
172| Array\<[ProxyRule](./arkts-apis-webview-ProxyRule.md)\> | Proxy rules.|
173
174**Example**
175
176For details about the sample code, see [removeProxyOverride](./arkts-apis-webview-ProxyController.md#removeproxyoverride15).
177
178## isReverseBypassEnabled<sup>15+</sup>
179
180isReverseBypassEnabled(): boolean
181
182Obtains the value of [enableReverseBypass](#enablereversebypass15). For details, see [enableReverseBypass](#enablereversebypass15).
183
184**System capability**: SystemCapability.Web.Webview.Core
185
186**Return value**
187
188| Type  | Description                     |
189| ------ | ------------------------- |
190| boolean | Value of [enableReverseBypass](#enablereversebypass15). The default value is **false**, indicating the bypass rule set in [insertBypassRule](#insertbypassrule15) is not reversed. The value **true** indicates the opposite.|
191
192**Example**
193
194For details about the sample code, see [removeProxyOverride](./arkts-apis-webview-ProxyController.md#removeproxyoverride15).
195