• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Class (WebResourceRequest)
2
3Implements the **WebResourceRequest** object to obtain resource requests. For details about the sample code, see [onErrorReceive](./arkts-basic-components-web-events.md#onerrorreceive).
4
5> **NOTE**
6>
7> - The initial APIs of this component are supported since API version 8. 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 8.
10>
11> - You can preview how this component looks on a real device, but not in DevEco Studio Previewer.
12
13## constructor
14
15constructor()
16
17Constructs a **WebResourceRequest** object.
18
19**System capability**: SystemCapability.Web.Webview.Core
20
21## getRequestHeader
22
23getRequestHeader(): Array\<Header\>
24
25Obtains the information about the resource request header.
26
27**System capability**: SystemCapability.Web.Webview.Core
28
29**Return value**
30
31| Type                        | Description        |
32| -------------------------- | ---------- |
33| Array\<[Header](./arkts-basic-components-web-i.md#header)\> | Information about the resource request header.|
34
35## getRequestUrl
36
37getRequestUrl(): string
38
39Obtains the URL of the resource request.
40
41**System capability**: SystemCapability.Web.Webview.Core
42
43**Return value**
44
45| Type    | Description           |
46| ------ | ------------- |
47| string | URL of the resource request.|
48
49## isMainFrame
50
51isMainFrame(): boolean
52
53Checks whether the resource request is for the main frame.
54
55**System capability**: SystemCapability.Web.Webview.Core
56
57**Return value**
58
59| Type     | Description              |
60| ------- | ---------------- |
61| boolean | Whether the resource request is for the main frame.<br>The value **true** indicates that the resource request is for the main frame, and **false** indicates the opposite.|
62
63## isRedirect
64
65isRedirect(): boolean
66
67Checks whether the resource request is redirected by the server.
68
69**System capability**: SystemCapability.Web.Webview.Core
70
71**Return value**
72
73| Type     | Description              |
74| ------- | ---------------- |
75| boolean | Whether the resource request is redirected by the server.<br>The value **true** indicates that the resource request is redirected by the server, and **false** indicates the opposite.|
76
77## isRequestGesture
78
79isRequestGesture(): boolean
80
81Checks whether the resource request is associated with a gesture (for example, a tap).
82
83**System capability**: SystemCapability.Web.Webview.Core
84
85**Return value**
86
87| Type     | Description                  |
88| ------- | -------------------- |
89| boolean | Whether the resource request is associated with a gesture (for example, a tap).<br>The value **true** indicates that the resource request is associated with a gesture, and **false** indicates the opposite.|
90
91## getRequestMethod<sup>9+</sup>
92
93getRequestMethod(): string
94
95Obtains the request method.
96
97**System capability**: SystemCapability.Web.Webview.Core
98
99**Return value**
100
101| Type    | Description     |
102| ------ | ------- |
103| string | Request method.|
104