• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# arkweb_scheme_handler.h
2
3## Overview
4
5Declares the APIs used to intercept requests from ArkWeb.
6
7**Library**: libohweb.so
8
9**System capability**: SystemCapability.Web.Webview.Core
10
11**Since**: 12
12
13**Related module**: [Web](capi-web.md)
14
15**Example**: <!--RP1-->[ArkWebSchemeHandler](https://gitee.com/openharmony/applications_app_samples/tree/master/code/DocsSample/ArkWeb/ArkWebSchemeHandler)<!--RP1End-->
16
17## Summary
18
19### Structs
20
21| Name| typedef Keyword| Description|
22| -- | -- | -- |
23| [ArkWeb_SchemeHandler_](capi-web-arkweb-schemehandler.md) | ArkWeb_SchemeHandler | Defines a handler used to intercept requests of a specified scheme.|
24| [ArkWeb_ResourceHandler_](capi-web-arkweb-resourcehandler.md) | ArkWeb_ResourceHandler | Defines a handler used to intercept URL requests. You can use **ArkWeb_ResourceHandler** to send custom request headers and bodies.|
25| [ArkWeb_Response_](capi-web-arkweb-response.md) | ArkWeb_Response | Defines an **ArkWeb_Response** for the intercepted request.|
26| [ArkWeb_ResourceRequest_](capi-web-arkweb-resourcerequest.md) | ArkWeb_ResourceRequest | Defines a kernel request. You can use **OH_ArkWeb_ResourceRequest** to obtain the URL, method, post data, and other information of the request.|
27| [ArkWeb_RequestHeaderList_](capi-web-arkweb-requestheaderlist.md) | ArkWeb_RequestHeaderList | Defines a request header list.|
28| [ArkWeb_HttpBodyStream_](capi-web-arkweb-httpbodystream.md) | ArkWeb_HttpBodyStream | Defines the uploaded data of a request. You can use the **OH_ArkWebHttpBodyStream_** API to read the uploaded data.|
29
30### Enums
31
32| Name| typedef Keyword| Description|
33| -- | -- | -- |
34| [ArkWeb_CustomSchemeOption](#arkweb_customschemeoption) | ArkWeb_CustomSchemeOption | Enumerates the custom scheme options.|
35| [ArkWeb_ResourceType](#arkweb_resourcetype) | ArkWeb_ResourceType | Enumerates the resource types. The resource types match the corresponding items of **ResourceType** in Chromium and should not be renumbered.|
36
37### Functions
38
39| Name| typedef Keyword| Description|
40| -- | -- | -- |
41| [typedef void (\*ArkWeb_OnRequestStart)(const ArkWeb_SchemeHandler* schemeHandler,ArkWeb_ResourceRequest* resourceRequest,const ArkWeb_ResourceHandler* resourceHandler,bool* intercept)](#arkweb_onrequeststart) | ArkWeb_OnRequestStart | Called when a request starts. This callback is used on the IO thread.|
42| [typedef void (\*ArkWeb_OnRequestStop)(const ArkWeb_SchemeHandler* schemeHandler,const ArkWeb_ResourceRequest* resourceRequest)](#arkweb_onrequeststop) | ArkWeb_OnRequestStop | Called when the request stops. This callback is used on the IO thread.<br>You can use **ArkWeb_ResourceRequest_Destroy** to destroy **resourceRequest**,<br>and **ArkWeb_ResourceHandler_Destroy** to destroy the **ArkWeb_ResourceHandler** received in **ArkWeb_OnRequestStart**.|
43| [typedef void (\*ArkWeb_HttpBodyStreamReadCallback)(const ArkWeb_HttpBodyStream* httpBodyStream,uint8_t* buffer,int bytesRead)](#arkweb_httpbodystreamreadcallback) | ArkWeb_HttpBodyStreamReadCallback | Called when **OH_ArkWebHttpBodyStream_Read** is complete.|
44| [typedef void (\*ArkWeb_HttpBodyStreamAsyncReadCallback)(const ArkWeb_HttpBodyStream* httpBodyStream,uint8_t* buffer,int bytesRead)](#arkweb_httpbodystreamasyncreadcallback) | ArkWeb_HttpBodyStreamAsyncReadCallback | Called when **OH_ArkWebHttpBodyStream_AsyncRead** is complete.|
45| [typedef void (\*ArkWeb_HttpBodyStreamInitCallback)(const ArkWeb_HttpBodyStream* httpBodyStream, ArkWeb_NetError result)](#arkweb_httpbodystreaminitcallback) | ArkWeb_HttpBodyStreamInitCallback | Called when **ArkWeb_HttpBodyStream** initialization is complete.|
46| [void OH_ArkWebRequestHeaderList_Destroy(ArkWeb_RequestHeaderList* requestHeaderList)](#oh_arkwebrequestheaderlist_destroy) | - | Destroys an **ArkWeb_RequestHeaderList** object.|
47| [int32_t OH_ArkWebRequestHeaderList_GetSize(const ArkWeb_RequestHeaderList* requestHeaderList)](#oh_arkwebrequestheaderlist_getsize) | - | Obtains the size of a request header list.|
48| [void OH_ArkWebRequestHeaderList_GetHeader(const ArkWeb_RequestHeaderList* requestHeaderList,int32_t index,char** key,char** value)](#oh_arkwebrequestheaderlist_getheader) | - | Obtains a specified request header.|
49| [int32_t OH_ArkWebResourceRequest_SetUserData(ArkWeb_ResourceRequest* resourceRequest, void* userData)](#oh_arkwebresourcerequest_setuserdata) | - | Sets user data to the **ArkWeb_ResourceRequest** object.|
50| [void* OH_ArkWebResourceRequest_GetUserData(const ArkWeb_ResourceRequest* resourceRequest)](#oh_arkwebresourcerequest_getuserdata) | - | Obtains user data from **ArkWeb_ResourceRequest**.|
51| [void OH_ArkWebResourceRequest_GetMethod(const ArkWeb_ResourceRequest* resourceRequest, char** method)](#oh_arkwebresourcerequest_getmethod) | - | Obtains the method of a request.|
52| [void OH_ArkWebResourceRequest_GetUrl(const ArkWeb_ResourceRequest* resourceRequest, char** url)](#oh_arkwebresourcerequest_geturl) | - | Obtains the URL of a request.|
53| [void OH_ArkWebResourceRequest_GetHttpBodyStream(const ArkWeb_ResourceRequest* resourceRequest,ArkWeb_HttpBodyStream** httpBodyStream)](#oh_arkwebresourcerequest_gethttpbodystream) | - | Creates an **ArkWeb_HttpBodyStream** to read the uploaded data of the request.|
54| [void OH_ArkWebResourceRequest_DestroyHttpBodyStream(ArkWeb_HttpBodyStream* httpBodyStream)](#oh_arkwebresourcerequest_destroyhttpbodystream) | - | Destroys an **ArkWeb_HttpBodyStream** object.|
55| [int32_t OH_ArkWebResourceRequest_GetResourceType(const ArkWeb_ResourceRequest* resourceRequest)](#oh_arkwebresourcerequest_getresourcetype) | - | Obtains the resource type of a request.|
56| [void OH_ArkWebResourceRequest_GetFrameUrl(const ArkWeb_ResourceRequest* resourceRequest, char** frameUrl)](#oh_arkwebresourcerequest_getframeurl) | - | Obtains the URL of the frame that triggers the request.|
57| [int32_t OH_ArkWebHttpBodyStream_SetUserData(ArkWeb_HttpBodyStream* httpBodyStream, void* userData)](#oh_arkwebhttpbodystream_setuserdata) | - | Sets user data to the **ArkWeb_HttpBodyStream** object.|
58| [void* OH_ArkWebHttpBodyStream_GetUserData(const ArkWeb_HttpBodyStream* httpBodyStream)](#oh_arkwebhttpbodystream_getuserdata) | - | Obtains user data from **ArkWeb_HttpBodyStream**.|
59| [int32_t OH_ArkWebHttpBodyStream_SetReadCallback(ArkWeb_HttpBodyStream* httpBodyStream,ArkWeb_HttpBodyStreamReadCallback readCallback)](#oh_arkwebhttpbodystream_setreadcallback) | - | Sets a callback for **OH_ArkWebHttpBodyStream_Read**. The result of **OH_ArkWebHttpBodyStream_Read** is notified to the caller through **readCallback**,<br>which will run in the same thread as **OH_ArkWebHttpBodyStream_Read**.|
60| [int32_t OH_ArkWebHttpBodyStream_SetAsyncReadCallback(ArkWeb_HttpBodyStream* httpBodyStream,ArkWeb_HttpBodyStreamReadCallback readCallback)](#oh_arkwebhttpbodystream_setasyncreadcallback) | - | Sets a callback for **OH_ArkWebHttpBodyStream_AsyncRead**. The result of **OH_ArkWebHttpBodyStream_AsyncRead** is notified to the caller through **readCallback**,<br>which will run in the same thread as **OH_ArkWebHttpBodyStream_AsyncRead**.|
61| [int32_t OH_ArkWebHttpBodyStream_Init(ArkWeb_HttpBodyStream* httpBodyStream,ArkWeb_HttpBodyStreamInitCallback initCallback)](#oh_arkwebhttpbodystream_init) | - | Initializes **ArkWeb_HttpBodyStream**. This API must be called on the I/O thread before any other API is called.|
62| [void OH_ArkWebHttpBodyStream_Read(const ArkWeb_HttpBodyStream* httpBodyStream, uint8_t* buffer, int bufLen)](#oh_arkwebhttpbodystream_read) | - | Exports the uploaded data of a request to the buffer. The buffer size must be greater than the value of **bufLen**. The data from the worker thread is exported to the buffer. Therefore, before the callback returns the data, the buffer should not be used in other threads to avoid concurrency problems.|
63| [void OH_ArkWebHttpBodyStream_AsyncRead(const ArkWeb_HttpBodyStream* httpBodyStream, uint8_t* buffer, int bufLen)](#oh_arkwebhttpbodystream_asyncread) | - | Exports the uploaded data of a request to the buffer. The buffer size must be greater than the value of **bufLen**. The data from the worker thread is exported to the buffer. Therefore, before the callback returns the data, the buffer should not be used in other threads to avoid concurrency problems.|
64| [uint64_t OH_ArkWebHttpBodyStream_GetSize(const ArkWeb_HttpBodyStream* httpBodyStream)](#oh_arkwebhttpbodystream_getsize) | - | Obtains the size of **httpBodyStream**. When data is chunked or **httpBodyStream** is invalid, **0** is always returned.|
65| [uint64_t OH_ArkWebHttpBodyStream_GetPosition(const ArkWeb_HttpBodyStream* httpBodyStream)](#oh_arkwebhttpbodystream_getposition) | - | Obtains the position of **httpBodyStream**.|
66| [bool OH_ArkWebHttpBodyStream_IsChunked(const ArkWeb_HttpBodyStream* httpBodyStream)](#oh_arkwebhttpbodystream_ischunked) | - | Determines whether **httpBodyStream** is chunked.|
67| [bool OH_ArkWebHttpBodyStream_IsEof(const ArkWeb_HttpBodyStream* httpBodyStream)](#oh_arkwebhttpbodystream_iseof) | - | Determines whether all data in **httpBodyStream** has been read. **true** is returned if all data in **httpBodyStream** has been read. **false** is returned before the chunked **httpBodyStream** is read for the first time.|
68| [bool OH_ArkWebHttpBodyStream_IsInMemory(const ArkWeb_HttpBodyStream* httpBodyStream)](#oh_arkwebhttpbodystream_isinmemory) | - | Determines whether all the uploaded data in **httpBodyStream** is in memory and all read requests are synchronized successfully. If yes, **true** is returned. **false** is returned if the data is chunked.|
69| [int32_t OH_ArkWebResourceRequest_Destroy(const ArkWeb_ResourceRequest* resourceRequest)](#oh_arkwebresourcerequest_destroy) | - | Destroys an **ArkWeb_ResourceRequest** object.|
70| [void OH_ArkWebResourceRequest_GetReferrer(const ArkWeb_ResourceRequest* resourceRequest, char** referrer)](#oh_arkwebresourcerequest_getreferrer) | - | Obtains the referrer of a request.|
71| [void OH_ArkWebResourceRequest_GetRequestHeaders(const ArkWeb_ResourceRequest* resourceRequest,ArkWeb_RequestHeaderList** requestHeaderList)](#oh_arkwebresourcerequest_getrequestheaders) | - | Obtains an **OH_ArkWeb_RequestHeaderList**.|
72| [bool OH_ArkWebResourceRequest_IsRedirect(const ArkWeb_ResourceRequest* resourceRequest)](#oh_arkwebresourcerequest_isredirect) | - | Determines whether a request is redirected.|
73| [bool OH_ArkWebResourceRequest_IsMainFrame(const ArkWeb_ResourceRequest* resourceRequest)](#oh_arkwebresourcerequest_ismainframe) | - | Determines whether a request is from main frame.|
74| [bool OH_ArkWebResourceRequest_HasGesture(const ArkWeb_ResourceRequest* resourceRequest)](#oh_arkwebresourcerequest_hasgesture) | - | Determines whether a request is triggered by a user gesture.|
75| [int32_t OH_ArkWeb_RegisterCustomSchemes(const char* scheme, int32_t option)](#oh_arkweb_registercustomschemes) | - | Registers a custom scheme with **ArkWeb**. This function should not be called for built-in HTTP, HTTPS, FILE, FTP, ABOUT, and DATA protocols.<br>This function should be called on the main thread before kernel initialization.|
76| [bool OH_ArkWebServiceWorker_SetSchemeHandler(const char* scheme, ArkWeb_SchemeHandler* schemeHandler)](#oh_arkwebserviceworker_setschemehandler) | - | Sets an **ArkWeb_SchemeHandler** for a specified scheme to intercept requests of the scheme type triggered by **ServiceWorker**. **SchemeHandler** should be set after **BrowserContext** is created.<br>You can use **WebviewController.initializeWebEngine** to initialize **BrowserContext** without creating the **Web** component.|
77| [bool OH_ArkWeb_SetSchemeHandler(const char* scheme, const char* webTag, ArkWeb_SchemeHandler* schemeHandler)](#oh_arkweb_setschemehandler) | - | Sets an **ArkWeb_SchemeHandler** to intercept requests of a specified scheme type. **SchemeHandler** should be set after **BrowserContext** is created.<br>You can use **WebviewController.initializeWebEngine** to initialize **BrowserContext** without creating the **Web** component.|
78| [int32_t OH_ArkWebServiceWorker_ClearSchemeHandlers()](#oh_arkwebserviceworker_clearschemehandlers) | - | Clears the **SchemeHandler** registered for **ServiceWorker**.|
79| [int32_t OH_ArkWeb_ClearSchemeHandlers(const char* webTag)](#oh_arkweb_clearschemehandlers) | - | Clears the **SchemeHandler** registered for the specified **Web** component.|
80| [void OH_ArkWeb_CreateSchemeHandler(ArkWeb_SchemeHandler** schemeHandler)](#oh_arkweb_createschemehandler) | - | Creates an **ArkWeb_SchemeHandler** object.|
81| [void OH_ArkWeb_DestroySchemeHandler(ArkWeb_SchemeHandler* schemeHandler)](#oh_arkweb_destroyschemehandler) | - | Destroys an **ArkWeb_SchemeHandler** object.|
82| [int32_t OH_ArkWebSchemeHandler_SetUserData(ArkWeb_SchemeHandler* schemeHandler, void* userData)](#oh_arkwebschemehandler_setuserdata) | - | Sets user data to the **ArkWeb_SchemeHandler** object.|
83| [void* OH_ArkWebSchemeHandler_GetUserData(const ArkWeb_SchemeHandler* schemeHandler)](#oh_arkwebschemehandler_getuserdata) | - | Obtains the user data from **ArkWeb_SchemeHandler**.|
84| [int32_t OH_ArkWebSchemeHandler_SetOnRequestStart(ArkWeb_SchemeHandler* schemeHandler,ArkWeb_OnRequestStart onRequestStart)](#oh_arkwebschemehandler_setonrequeststart) | - | Sets an **OnRequestStart** callback for **SchemeHandler**.|
85| [int32_t OH_ArkWebSchemeHandler_SetOnRequestStop(ArkWeb_SchemeHandler* schemeHandler,ArkWeb_OnRequestStop onRequestStop)](#oh_arkwebschemehandler_setonrequeststop) | - | Sets an **OnRequestStop** callback for **SchemeHandler**.|
86| [void OH_ArkWeb_CreateResponse(ArkWeb_Response** response)](#oh_arkweb_createresponse) | - | Creates an **ArkWeb_Response** object for the intercepted request.|
87| [void OH_ArkWeb_DestroyResponse(ArkWeb_Response* response)](#oh_arkweb_destroyresponse) | - | Destroys an **ArkWeb_Response** object.|
88| [int32_t OH_ArkWebResponse_SetUrl(ArkWeb_Response* response, const char* url)](#oh_arkwebresponse_seturl) | - | Sets a parsed URL that has been redirected or changed due to HSTS. After the setting, redirection is triggered.|
89| [void OH_ArkWebResponse_GetUrl(const ArkWeb_Response* response, char** url)](#oh_arkwebresponse_geturl) | - | Obtains the parsed URL that has been redirected or changed due to HSTS.|
90| [int32_t OH_ArkWebResponse_SetError(ArkWeb_Response* response, ArkWeb_NetError errorCode)](#oh_arkwebresponse_seterror) | - | Sets an error code for the **ArkWeb_Response** object.|
91| [ArkWeb_NetError OH_ArkWebResponse_GetError(const ArkWeb_Response* response)](#oh_arkwebresponse_geterror) | - | Obtains the error code of **ArkWeb_Response**.|
92| [int32_t OH_ArkWebResponse_SetStatus(ArkWeb_Response* response, int status)](#oh_arkwebresponse_setstatus) | - | Sets an HTTP status code for **ArkWeb_Response**.|
93| [int OH_ArkWebResponse_GetStatus(const ArkWeb_Response* response)](#oh_arkwebresponse_getstatus) | - | Obtains the HTTP status code of **ArkWeb_Response**.|
94| [int32_t OH_ArkWebResponse_SetStatusText(ArkWeb_Response* response, const char* statusText)](#oh_arkwebresponse_setstatustext) | - | Sets a status text for **ArkWeb_Response**.|
95| [void OH_ArkWebResponse_GetStatusText(const ArkWeb_Response* response, char** statusText)](#oh_arkwebresponse_getstatustext) | - | Obtains the status text of **ArkWeb_Response**.|
96| [int32_t OH_ArkWebResponse_SetMimeType(ArkWeb_Response* response, const char* mimeType)](#oh_arkwebresponse_setmimetype) | - | Sets a mime type for **ArkWeb_Response**.|
97| [void OH_ArkWebResponse_GetMimeType(const ArkWeb_Response* response, char** mimeType)](#oh_arkwebresponse_getmimetype) | - | Obtains the mime type of **ArkWeb_Response**.|
98| [int32_t OH_ArkWebResponse_SetCharset(ArkWeb_Response* response, const char* charset)](#oh_arkwebresponse_setcharset) | - | Sets a character set for **ArkWeb_Response**.|
99| [void OH_ArkWebResponse_GetCharset(const ArkWeb_Response* response, char** charset)](#oh_arkwebresponse_getcharset) | - | Obtains the character set of **ArkWeb_Response**.|
100| [int32_t OH_ArkWebResponse_SetHeaderByName(ArkWeb_Response* response,const char* name,const char* value,bool overwrite)](#oh_arkwebresponse_setheaderbyname) | - | Sets a header for **ArkWeb_Response**.|
101| [void OH_ArkWebResponse_GetHeaderByName(const ArkWeb_Response* response, const char* name, char** value)](#oh_arkwebresponse_getheaderbyname) | - | Obtains the header from **ArkWeb_Response**.|
102| [int32_t OH_ArkWebResourceHandler_Destroy(const ArkWeb_ResourceHandler* resourceHandler)](#oh_arkwebresourcehandler_destroy) | - | Destroys an **ArkWeb_ResourceHandler** object.|
103| [int32_t OH_ArkWebResourceHandler_DidReceiveResponse(const ArkWeb_ResourceHandler* resourceHandler,const ArkWeb_Response* response)](#oh_arkwebresourcehandler_didreceiveresponse) | - | Sends a response header to the intercepted request.|
104| [int32_t OH_ArkWebResourceHandler_DidReceiveData(const ArkWeb_ResourceHandler* resourceHandler,const uint8_t* buffer,int64_t bufLen)](#oh_arkwebresourcehandler_didreceivedata) | - | Sends a response body to the intercepted request.|
105| [int32_t OH_ArkWebResourceHandler_DidFinish(const ArkWeb_ResourceHandler* resourceHandler)](#oh_arkwebresourcehandler_didfinish) | - | Notifies the ArkWeb kernel that the intercepted request has been finished and that no more data is available.|
106| [int32_t OH_ArkWebResourceHandler_DidFailWithError(const ArkWeb_ResourceHandler* resourceHandler,ArkWeb_NetError errorCode)](#oh_arkwebresourcehandler_didfailwitherror) | - | Notifies the ArkWeb kernel that the intercepted request fails.|
107| [void OH_ArkWeb_ReleaseString(char* string)](#oh_arkweb_releasestring) | - | Releases the string created by NDK APIs.|
108| [void OH_ArkWeb_ReleaseByteArray(uint8_t* byteArray)](#oh_arkweb_releasebytearray) | - | Releases the byte array created by NDK APIs.|
109
110## Enum Description
111
112### ArkWeb_CustomSchemeOption
113
114```
115enum ArkWeb_CustomSchemeOption
116```
117
118**Description**
119
120Enumerates the custom scheme options.
121
122**System capability**: SystemCapability.Web.Webview.Core
123
124**Since**: 12
125
126| Enumerated Value| Description|
127| -- | -- |
128| ARKWEB_SCHEME_OPTION_STANDARD = 1 << 0 | The scheme is processed as a standard scheme.|
129| ARKWEB_SCHEME_OPTION_LOCAL = 1 << 1 | The scheme is processed using the same security rule as the file URL.|
130| ARKWEB_SCHEME_OPTION_DISPLAY_ISOLATED = 1 << 2 | The request of the scheme can be initiated only by the page that is loaded using the same scheme.|
131| ARKWEB_SCHEME_OPTION_SECURE = 1 << 3 | The scheme is processed using the same security rule as the HTTPS URL.|
132| ARKWEB_SCHEME_OPTION_CORS_ENABLED = 1 << 4 | The scheme can send CORS requests. In most cases, this value should be set when **ARKWEB_SCHEME_OPTION_STANDARD** is set.|
133| ARKWEB_SCHEME_OPTION_CSP_BYPASSING = 1 << 5 | The scheme can bypass the Content Security Policy (CSP) check.|
134| ARKWEB_SCHEME_OPTION_FETCH_ENABLED = 1 << 6 | The FETCH API request of the scheme can be initiated.|
135| ARKWEB_SCHEME_OPTION_CODE_CACHE_ENABLED = 1 << 7 | The JS resources of the scheme support code cache generation.|
136
137### ArkWeb_ResourceType
138
139```
140enum ArkWeb_ResourceType
141```
142
143**Description**
144
145Enumerates the resource types. The resource types match the corresponding items of **ResourceType** in Chromium and should not be renumbered.<br>
146
147**System capability**: SystemCapability.Web.Webview.Core
148
149**Since**: 12
150
151| Enumerated Value| Description|
152| -- | -- |
153| MAIN_FRAME = 0 | Main frame.|
154| SUB_FRAME = 1 | Frame or iframe.|
155| STYLE_SHEET = 2 | Cascading Style Sheets (CSS).|
156| SCRIPT = 3 | External script.|
157| IMAGE = 4 | Image (JPG, GIF, PNG, or other format).|
158| FONT_RESOURCE = 5 | Font.|
159| SUB_RESOURCE = 6 | Other sub-resource. If the type is unknown, the default type is used.|
160| OBJECT = 7 | The **Object** (or **embed**) tag of the plug-in, or the resource requested by the plug-in.|
161| MEDIA = 8 | Media resource|
162| WORKER = 9 | Main resource of the dedicated worker thread.|
163| SHARED_WORKER = 10 | Main resource of a shared worker thread.|
164| PREFETCH = 11 | Explicit prefetch request.|
165| FAVICON = 12 | Website icon.|
166| XHR = 13 | XMLHttpRequest.|
167| PING = 14 | Ping request of **/sendBeacon**.|
168| SERVICE_WORKER = 15 | Main resource of a service worker.|
169| CSP_REPORT = 16 | Report of Content Security Policy violation.|
170| PLUGIN_RESOURCE = 17 | Resource requested by the plug-in.|
171| NAVIGATION_PRELOAD_MAIN_FRAME = 19 | Main frame redirection request that triggers service worker preloading.|
172| NAVIGATION_PRELOAD_SUB_FRAME = 20 | Subframe redirection request that triggers service worker preloading.|
173
174
175## Function Description
176
177### ArkWeb_OnRequestStart()
178
179```
180typedef void (*ArkWeb_OnRequestStart)(const ArkWeb_SchemeHandler* schemeHandler,ArkWeb_ResourceRequest* resourceRequest,const ArkWeb_ResourceHandler* resourceHandler,bool* intercept)
181```
182
183**Description**
184
185Called when a request starts. This callback is used on the IO thread.
186
187**System capability**: SystemCapability.Web.Webview.Core
188
189**Since**: 12
190
191
192**Parameters**
193
194| Name                                                                       | Description|
195|----------------------------------------------------------------------------| -- |
196| const [ArkWeb_SchemeHandler](capi-web-arkweb-schemehandler.md)* schemeHandler | **ArkWeb_SchemeHandler**.|
197| [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | Object used to obtain the request information.|
198| const [ArkWeb_ResourceHandler](capi-web-arkweb-resourcehandler.md)* resourceHandler                          | **ArkWeb_ResourceHandler** of the request. If **intercept** is set to **false**, this parameter should not be used.|
199| bool* intercept                                                            | Whether to intercept the request. If the value is **true**, the request will be intercepted. Otherwise, the request will not be intercepted.|
200
201### ArkWeb_OnRequestStop()
202
203```
204typedef void (*ArkWeb_OnRequestStop)(const ArkWeb_SchemeHandler* schemeHandler,const ArkWeb_ResourceRequest* resourceRequest)
205```
206
207**Description**
208
209Called when the request stops. This callback is used on the IO thread.
210
211You can use **ArkWeb_ResourceRequest_Destroy** to destroy the **resourceRequest** and use **ArkWeb_ResourceHandler_Destroy** to destroy the **ArkWeb_ResourceHandler** received in **ArkWeb_OnRequestStart**.
212
213**System capability**: SystemCapability.Web.Webview.Core
214
215**Since**: 12
216
217
218**Parameters**
219
220| Name| Description|
221| -- | -- |
222| const [ArkWeb_SchemeHandler](capi-web-arkweb-schemehandler.md)* schemeHandler | **ArkWeb_SchemeHandler**.|
223| const [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
224
225### ArkWeb_HttpBodyStreamReadCallback()
226
227```
228typedef void (*ArkWeb_HttpBodyStreamReadCallback)(const ArkWeb_HttpBodyStream* httpBodyStream,uint8_t* buffer,int bytesRead)
229```
230
231**Description**
232
233Called when **OH_ArkWebHttpBodyStream_Read** is complete.
234
235**System capability**: SystemCapability.Web.Webview.Core
236
237**Since**: 12
238
239
240**Parameters**
241
242| Name                                            | Description|
243|-------------------------------------------------| -- |
244| const [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
245| uint8_t* buffer                                 | Buffer for receiving data.|
246| int bytesRead                                   | Callback used when **OH_ArkWebHttpBodyStream_Read** is complete. If the value of **bytesRead** is greater than 0, the **buffer** is filled with data of the **bytesRead** size. The caller can read data from the **buffer**. If **OH_ArkWebHttpBodyStream_IsEOF** is **false**, the caller can continue to read the data left.|
247
248### ArkWeb_HttpBodyStreamAsyncReadCallback()
249
250```
251typedef void (*ArkWeb_HttpBodyStreamAsyncReadCallback)(const ArkWeb_HttpBodyStream *httpBodyStream,uint8_t *buffer,int bytesRead)
252```
253
254**Description**
255
256Called when **OH_ArkWebHttpBodyStream_AsyncRead** is complete.
257
258**System capability**: SystemCapability.Web.Webview.Core
259
260**Since**: 20
261
262
263**Parameters**
264
265| Name                                            | Description|
266|-------------------------------------------------| -- |
267| const [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
268| uint8_t* buffer                                 | Buffer for receiving data.|
269| int bytesRead                                   | Byte count value of the asynchronous read operation result. If the value of **bytesRead** is greater than 0, the **buffer** is filled with data of the **bytesRead** size. You can read data from the **buffer**. If **OH_ArkWebHttpBodyStream_IsEOF** is false, you can continue to read the data left.|
270
271### ArkWeb_HttpBodyStreamInitCallback()
272
273```
274typedef void (*ArkWeb_HttpBodyStreamInitCallback)(const ArkWeb_HttpBodyStream* httpBodyStream, ArkWeb_NetError result)
275```
276
277**Description**
278
279Called when **ArkWeb_HttpBodyStream** initialization is complete.
280
281**System capability**: SystemCapability.Web.Webview.Core
282
283**Since**: 12
284
285**Parameters**
286
287| Name                                                                          | Description|
288|-------------------------------------------------------------------------------| -- |
289| const [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
290| [ArkWeb_NetError](capi-arkweb-net-error-list-h.md#arkweb_neterror) result     | Operation result. If the operation is successful, **ARKWEB_NET_OK** is returned. Otherwise, see [arkweb_net_error_list.h](capi-arkweb-net-error-list-h.md).|
291
292### OH_ArkWebRequestHeaderList_Destroy()
293
294```
295void OH_ArkWebRequestHeaderList_Destroy(ArkWeb_RequestHeaderList* requestHeaderList)
296```
297
298**Description**
299
300Destroys an **ArkWeb_RequestHeaderList** object.
301
302**System capability**: SystemCapability.Web.Webview.Core
303
304**Since**: 12
305
306
307**Parameters**
308
309| Name| Description|
310| -- | -- |
311| [ArkWeb_RequestHeaderList](capi-web-arkweb-requestheaderlist.md)* requestHeaderList | The **ArkWeb_RequestHeaderList** to be destroyed.|
312
313### OH_ArkWebRequestHeaderList_GetSize()
314
315```
316int32_t OH_ArkWebRequestHeaderList_GetSize(const ArkWeb_RequestHeaderList* requestHeaderList)
317```
318
319**Description**
320
321Obtains the size of a request header list.
322
323**System capability**: SystemCapability.Web.Webview.Core
324
325**Since**: 12
326
327
328**Parameters**
329
330| Name| Description|
331| -- | -- |
332| const [ArkWeb_RequestHeaderList](capi-web-arkweb-requestheaderlist.md)* requestHeaderList | Request header list.|
333
334**Returns**
335
336| Type| Description|
337| -- | -- |
338| int32_t | Size of the request header. If **requestHeaderList** is invalid, the value is **-1**.|
339
340### OH_ArkWebRequestHeaderList_GetHeader()
341
342```
343void OH_ArkWebRequestHeaderList_GetHeader(const ArkWeb_RequestHeaderList* requestHeaderList,int32_t index,char** key,char** value)
344```
345
346**Description**
347
348Obtains a specified request header.
349
350**System capability**: SystemCapability.Web.Webview.Core
351
352**Since**: 12
353
354
355**Parameters**
356
357| Name| Description|
358| -- | -- |
359| const ArkWeb_RequestHeaderList* requestHeaderList | Request header list.|
360| int32_t index | Index of the request header.|
361| char** key | Key of the request header. You should use the **OH_ArkWeb_ReleaseString** function to release this string.|
362| char** value | Value of the request header. You should use the **OH_ArkWeb_ReleaseString** function to release this string.|
363
364### OH_ArkWebResourceRequest_SetUserData()
365
366```
367int32_t OH_ArkWebResourceRequest_SetUserData(ArkWeb_ResourceRequest* resourceRequest, void* userData)
368```
369
370**Description**
371
372Sets user data to the **ArkWeb_ResourceRequest** object.
373
374**System capability**: SystemCapability.Web.Webview.Core
375
376**Since**: 12
377
378
379**Parameters**
380
381| Name| Description|
382| -- | -- |
383| [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
384| void* userData | User data to be set.|
385
386**Returns**
387
388| Type| Description|
389| -- | -- |
390| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
391
392### OH_ArkWebResourceRequest_GetUserData()
393
394```
395void* OH_ArkWebResourceRequest_GetUserData(const ArkWeb_ResourceRequest* resourceRequest)
396```
397
398**Description**
399
400Obtains user data from **ArkWeb_ResourceRequest**.
401
402**System capability**: SystemCapability.Web.Webview.Core
403
404**Since**: 12
405
406
407**Parameters**
408
409| Name| Description|
410| -- | -- |
411| const [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
412
413**Returns**
414
415| Type| Description|
416| -- | -- |
417| void* | User data.|
418
419### OH_ArkWebResourceRequest_GetMethod()
420
421```
422void OH_ArkWebResourceRequest_GetMethod(const ArkWeb_ResourceRequest* resourceRequest, char** method)
423```
424
425**Description**
426
427Obtains the method of a request.
428
429**System capability**: SystemCapability.Web.Webview.Core
430
431**Since**: 12
432
433
434**Parameters**
435
436| Name| Description|
437| -- | -- |
438| const [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
439| char** method | HTTP request method. This function allocates memory for the **method** string. You should use **OH_ArkWeb_ReleaseString** to release the string.|
440
441### OH_ArkWebResourceRequest_GetUrl()
442
443```
444void OH_ArkWebResourceRequest_GetUrl(const ArkWeb_ResourceRequest* resourceRequest, char** url)
445```
446
447**Description**
448
449Obtains the URL of a request.
450
451**System capability**: SystemCapability.Web.Webview.Core
452
453**Since**: 12
454
455
456**Parameters**
457
458| Name| Description|
459| -- | -- |
460| const [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
461| char** url | URL of a request. This function allocates memory for the **url** string. You should release the string using **OH_ArkWeb_ReleaseString**.|
462
463### OH_ArkWebResourceRequest_GetHttpBodyStream()
464
465```
466void OH_ArkWebResourceRequest_GetHttpBodyStream(const ArkWeb_ResourceRequest* resourceRequest,ArkWeb_HttpBodyStream** httpBodyStream)
467```
468
469**Description**
470
471Creates an **ArkWeb_HttpBodyStream** to read the uploaded data of the request.
472
473**System capability**: SystemCapability.Web.Webview.Core
474
475**Since**: 12
476
477
478**Parameters**
479
480| Name| Description|
481| -- | -- |
482| const [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
483| [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)** httpBodyStream | Uploaded data of the request. This function allocates memory for **httpBodyStream**. You should use **OH_ArkWebResourceRequest_DestroyHttpBodyStream** to release **httpBodyStream**.|
484
485### OH_ArkWebResourceRequest_DestroyHttpBodyStream()
486
487```
488void OH_ArkWebResourceRequest_DestroyHttpBodyStream(ArkWeb_HttpBodyStream* httpBodyStream)
489```
490
491**Description**
492
493Destroys an **ArkWeb_HttpBodyStream** object.
494
495**System capability**: SystemCapability.Web.Webview.Core
496
497**Since**: 12
498
499
500**Parameters**
501
502| Name| Description|
503| -- | -- |
504| [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | The **httpBodyStream** to be destroyed.|
505
506### OH_ArkWebResourceRequest_GetResourceType()
507
508```
509int32_t OH_ArkWebResourceRequest_GetResourceType(const ArkWeb_ResourceRequest* resourceRequest)
510```
511
512**Description**
513
514Obtains the resource type of a request.
515
516**System capability**: SystemCapability.Web.Webview.Core
517
518**Since**: 12
519
520
521**Parameters**
522
523| Name| Description|
524| -- | -- |
525| const [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
526
527**Returns**
528
529| Type| Description|
530| -- | -- |
531| int32_t | Resource type of a request. If **resourceRequest** is invalid, the value is **-1**.|
532
533### OH_ArkWebResourceRequest_GetFrameUrl()
534
535```
536void OH_ArkWebResourceRequest_GetFrameUrl(const ArkWeb_ResourceRequest* resourceRequest, char** frameUrl)
537```
538
539**Description**
540
541Obtains the URL of the frame that triggers this request.
542
543**System capability**: SystemCapability.Web.Webview.Core
544
545**Since**: 12
546
547
548**Parameters**
549
550| Name| Description|
551| -- | -- |
552| const [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
553| char** frameUrl | URL of the frame that triggers the request. This function allocates memory for the URL string. You should release the string using **OH_ArkWeb_ReleaseString**.|
554
555### OH_ArkWebHttpBodyStream_SetUserData()
556
557```
558int32_t OH_ArkWebHttpBodyStream_SetUserData(ArkWeb_HttpBodyStream* httpBodyStream, void* userData)
559```
560
561**Description**
562
563Sets user data to the **ArkWeb_HttpBodyStream** object.
564
565**System capability**: SystemCapability.Web.Webview.Core
566
567**Since**: 12
568
569
570**Parameters**
571
572| Name| Description|
573| -- | -- |
574| [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
575| void* userData | User data to be set.|
576
577**Returns**
578
579| Type| Description|
580| -- | -- |
581| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
582
583### OH_ArkWebHttpBodyStream_GetUserData()
584
585```
586void* OH_ArkWebHttpBodyStream_GetUserData(const ArkWeb_HttpBodyStream* httpBodyStream)
587```
588
589**Description**
590
591Obtains user data from **ArkWeb_HttpBodyStream**.
592
593**System capability**: SystemCapability.Web.Webview.Core
594
595**Since**: 12
596
597
598**Parameters**
599
600| Name| Description|
601| -- | -- |
602| const [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
603
604**Returns**
605
606| Type| Description|
607| -- | -- |
608| void* | User data.|
609
610### OH_ArkWebHttpBodyStream_SetReadCallback()
611
612```
613int32_t OH_ArkWebHttpBodyStream_SetReadCallback(ArkWeb_HttpBodyStream* httpBodyStream,ArkWeb_HttpBodyStreamReadCallback readCallback)
614```
615
616**Description**
617
618Sets a callback for **OH_ArkWebHttpBodyStream_Read**. The result of **OH_ArkWebHttpBodyStream_Read** is notified to the caller through **readCallback**,<br>which will run in the same thread as **OH_ArkWebHttpBodyStream_Read**.
619
620**System capability**: SystemCapability.Web.Webview.Core
621
622**Since**: 12
623
624
625**Parameters**
626
627| Name| Description|
628| -- | -- |
629| [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
630| [ArkWeb_HttpBodyStreamReadCallback](#arkweb_httpbodystreamreadcallback) readCallback | Callback of **OH_ArkWebHttpBodyStream_Read**.|
631
632**Returns**
633
634| Type| Description|
635| -- | -- |
636| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
637
638### OH_ArkWebHttpBodyStream_SetAsyncReadCallback()
639
640```
641int32_t OH_ArkWebHttpBodyStream_SetAsyncReadCallback(ArkWeb_HttpBodyStream* httpBodyStream,ArkWeb_HttpBodyStreamAsyncReadCallback readCallback)
642```
643
644**Description**
645
646Sets a callback for **OH_ArkWebHttpBodyStream_AsyncRead**. The result of **OH_ArkWebHttpBodyStream_AsyncRead** is notified to the caller through **readCallback**,<br>which runs in the ArkWeb worker thread.
647
648**System capability**: SystemCapability.Web.Webview.Core
649
650**Since**: 20
651
652
653**Parameters**
654
655| Name| Description|
656| -- | -- |
657| [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
658| [ArkWeb_HttpBodyStreamAsyncReadCallback](#arkweb_httpbodystreamasyncreadcallback) readCallback | Callback of **OH_ArkWebHttpBodyStream_AsyncRead**.|
659
660**Returns**
661
662| Type| Description|
663| -- | -- |
664| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
665
666
667### OH_ArkWebHttpBodyStream_Init()
668
669```
670int32_t OH_ArkWebHttpBodyStream_Init(ArkWeb_HttpBodyStream* httpBodyStream,ArkWeb_HttpBodyStreamInitCallback initCallback)
671```
672
673**Description**
674
675Initializes **ArkWeb_HttpBodyStream**. This API must be called on the I/O thread before any other API is called.
676
677**System capability**: SystemCapability.Web.Webview.Core
678
679**Since**: 12
680
681
682**Parameters**
683
684| Name| Description|
685| -- | -- |
686| [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
687| [ArkWeb_HttpBodyStreamInitCallback](#arkweb_httpbodystreaminitcallback) initCallback | Callback of the initialization.|
688
689**Returns**
690
691| Type| Description|
692| -- | -- |
693| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
694
695### OH_ArkWebHttpBodyStream_Read()
696
697```
698void OH_ArkWebHttpBodyStream_Read(const ArkWeb_HttpBodyStream* httpBodyStream, uint8_t* buffer, int bufLen)
699```
700
701**Description**
702
703Exports the uploaded data of a request to the buffer. The buffer size must be greater than the value of **bufLen**. The data from the worker thread is exported to the buffer. Therefore, before the callback returns the data, the buffer should not be used in other threads to avoid concurrency problems.
704
705**System capability**: SystemCapability.Web.Webview.Core
706
707**Since**: 12
708
709
710**Parameters**
711
712| Name| Description|
713| -- | -- |
714| const [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
715| uint8_t* buffer | Buffer for receiving data.|
716| int bufLen | Size of the byte to be read.|
717
718### OH_ArkWebHttpBodyStream_AsyncRead()
719
720```
721void OH_ArkWebHttpBodyStream_AsyncRead(const ArkWeb_HttpBodyStream* httpBodyStream, uint8_t* buffer, int bufLen)
722```
723
724**Description**
725
726Exports the uploaded data of a request to the buffer. The buffer size must be greater than the value of **bufLen**.  The data from the worker thread is exported to the buffer. Therefore, before the callback returns the data, the buffer should not be used in other threads to avoid concurrency problems.
727
728**System capability**: SystemCapability.Web.Webview.Core
729
730**Since**: 20
731
732
733**Parameters**
734
735| Name| Description|
736| -- | -- |
737| const [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
738| uint8_t* buffer | Buffer for receiving data.|
739| int bufLen | Size of the byte to be read.|
740
741### OH_ArkWebHttpBodyStream_GetSize()
742
743```
744uint64_t OH_ArkWebHttpBodyStream_GetSize(const ArkWeb_HttpBodyStream* httpBodyStream)
745```
746
747**Description**
748
749Obtains the size of **httpBodyStream**. When data is chunked or **httpBodyStream** is invalid, **0** is always returned.
750
751**System capability**: SystemCapability.Web.Webview.Core
752
753**Since**: 12
754
755
756**Parameters**
757
758| Name| Description|
759| -- | -- |
760| const [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
761
762**Returns**
763
764| Type| Description|
765| -- | -- |
766| uint64_t | Size of **httpBodyStream**.|
767
768### OH_ArkWebHttpBodyStream_GetPosition()
769
770```
771uint64_t OH_ArkWebHttpBodyStream_GetPosition(const ArkWeb_HttpBodyStream* httpBodyStream)
772```
773
774**Description**
775
776Obtains the position of **httpBodyStream**.
777
778**System capability**: SystemCapability.Web.Webview.Core
779
780**Since**: 12
781
782
783**Parameters**
784
785| Name| Description|
786| -- | -- |
787| const [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
788
789**Returns**
790
791| Type| Description|
792| -- | -- |
793| uint64_t | Position of **httpBodyStream**. If **httpBodyStream** is invalid, the position value is **0**.|
794
795### OH_ArkWebHttpBodyStream_IsChunked()
796
797```
798bool OH_ArkWebHttpBodyStream_IsChunked(const ArkWeb_HttpBodyStream* httpBodyStream)
799```
800
801**Description**
802
803Determines whether **httpBodyStream** is chunked.
804
805**System capability**: SystemCapability.Web.Webview.Core
806
807**Since**: 12
808
809
810**Parameters**
811
812| Name| Description|
813| -- | -- |
814| const [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
815
816**Returns**
817
818| Type| Description|
819| -- | -- |
820| bool | **true** is returned if **httpBodyStream** is chunked. Otherwise, **false** is returned.|
821
822### OH_ArkWebHttpBodyStream_IsEof()
823
824```
825bool OH_ArkWebHttpBodyStream_IsEof(const ArkWeb_HttpBodyStream* httpBodyStream)
826```
827
828**Description**
829
830Determines whether all data in **httpBodyStream** has been read. **true** is returned if all data in **httpBodyStream** has been read. **false** is returned before the chunked **httpBodyStream** is read for the first time.
831
832**System capability**: SystemCapability.Web.Webview.Core
833
834**Since**: 12
835
836
837**Parameters**
838
839| Name| Description|
840| -- | -- |
841| const [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
842
843**Returns**
844
845| Type| Description|
846| -- | -- |
847| bool | **true** is returned if all data has been read. Otherwise, **false** is returned.|
848
849### OH_ArkWebHttpBodyStream_IsInMemory()
850
851```
852bool OH_ArkWebHttpBodyStream_IsInMemory(const ArkWeb_HttpBodyStream* httpBodyStream)
853```
854
855**Description**
856
857Determines whether all the uploaded data in **httpBodyStream** is in memory and all read requests are synchronized successfully. If yes, **true** is returned. **false** is returned if the data is chunked.
858
859**System capability**: SystemCapability.Web.Webview.Core
860
861**Since**: 12
862
863
864**Parameters**
865
866| Name| Description|
867| -- | -- |
868| const [ArkWeb_HttpBodyStream](capi-web-arkweb-httpbodystream.md)* httpBodyStream | **ArkWeb_HttpBodyStream**.|
869
870**Returns**
871
872| Type| Description|
873| -- | -- |
874| bool | **true** is returned if all the uploaded data is stored in the memory. Otherwise, **false** is returned.|
875
876### OH_ArkWebResourceRequest_Destroy()
877
878```
879int32_t OH_ArkWebResourceRequest_Destroy(const ArkWeb_ResourceRequest* resourceRequest)
880```
881
882**Description**
883
884Destroys an **ArkWeb_ResourceRequest** object.
885
886**System capability**: SystemCapability.Web.Webview.Core
887
888**Since**: 12
889
890
891**Parameters**
892
893| Name| Description|
894| -- | -- |
895| const [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
896
897**Returns**
898
899| Type| Description|
900| -- | -- |
901| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
902
903### OH_ArkWebResourceRequest_GetReferrer()
904
905```
906void OH_ArkWebResourceRequest_GetReferrer(const ArkWeb_ResourceRequest* resourceRequest, char** referrer)
907```
908
909**Description**
910
911Obtains the referrer of a request.
912
913**System capability**: SystemCapability.Web.Webview.Core
914
915**Since**: 12
916
917
918**Parameters**
919
920| Name| Description|
921| -- | -- |
922| const [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
923| char** referrer | **referrer** of a request. This function allocates memory for the **referrer** string. You should use **OH_ArkWeb_ReleaseString** to release the string.|
924
925### OH_ArkWebResourceRequest_GetRequestHeaders()
926
927```
928void OH_ArkWebResourceRequest_GetRequestHeaders(const ArkWeb_ResourceRequest* resourceRequest,ArkWeb_RequestHeaderList** requestHeaderList)
929```
930
931**Description**
932
933Obtains an **OH_ArkWeb_RequestHeaderList**.
934
935**System capability**: SystemCapability.Web.Webview.Core
936
937**Since**: 12
938
939
940**Parameters**
941
942| Name| Description|
943| -- | -- |
944| const [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
945| [ArkWeb_RequestHeaderList](capi-web-arkweb-requestheaderlist.md)** requestHeaderList | List of request headers.|
946
947### OH_ArkWebResourceRequest_IsRedirect()
948
949```
950bool OH_ArkWebResourceRequest_IsRedirect(const ArkWeb_ResourceRequest* resourceRequest)
951```
952
953**Description**
954
955Determines whether a request is redirected.
956
957**System capability**: SystemCapability.Web.Webview.Core
958
959**Since**: 12
960
961
962**Parameters**
963
964| Name| Description|
965| -- | -- |
966| const [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
967
968**Returns**
969
970| Type| Description|
971| -- | -- |
972| bool | **true** is returned if this request is redirected. Otherwise, **false** is returned.|
973
974### OH_ArkWebResourceRequest_IsMainFrame()
975
976```
977bool OH_ArkWebResourceRequest_IsMainFrame(const ArkWeb_ResourceRequest* resourceRequest)
978```
979
980**Description**
981
982Determines whether a request is from main frame.
983
984**System capability**: SystemCapability.Web.Webview.Core
985
986**Since**: 12
987
988
989**Parameters**
990
991| Name| Description|
992| -- | -- |
993| const [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
994
995**Returns**
996
997| Type| Description|
998| -- | -- |
999| bool | **true** is returned if this request is from the main framework. Otherwise, **false** is returned.|
1000
1001### OH_ArkWebResourceRequest_HasGesture()
1002
1003```
1004bool OH_ArkWebResourceRequest_HasGesture(const ArkWeb_ResourceRequest* resourceRequest)
1005```
1006
1007**Description**
1008
1009Determines whether a request is triggered by a user gesture.
1010
1011**System capability**: SystemCapability.Web.Webview.Core
1012
1013**Since**: 12
1014
1015
1016**Parameters**
1017
1018| Name| Description|
1019| -- | -- |
1020| const [ArkWeb_ResourceRequest](capi-web-arkweb-resourcerequest.md)* resourceRequest | **ArkWeb_ResourceRequest**.|
1021
1022**Returns**
1023
1024| Type| Description|
1025| -- | -- |
1026| bool | **true** is returned if this request is triggered by a user gesture. Otherwise, **false** is returned.|
1027
1028### OH_ArkWeb_RegisterCustomSchemes()
1029
1030```
1031int32_t OH_ArkWeb_RegisterCustomSchemes(const char* scheme, int32_t option)
1032```
1033
1034**Description**
1035
1036Registers a custom scheme with **ArkWeb**. This function should not be called for built-in HTTP, HTTPS, FILE, FTP, ABOUT, and DATA protocols. This function should be called on the main thread before kernel initialization.
1037
1038**System capability**: SystemCapability.Web.Webview.Core
1039
1040**Since**: 12
1041
1042
1043**Parameters**
1044
1045| Name| Description|
1046| -- | -- |
1047| const char* scheme | Scheme to be registered.|
1048| int32_t option | Scheme options.|
1049
1050**Returns**
1051
1052| Type| Description|
1053| -- | -- |
1054| int32_t | **0** is returned if the operation is successful. **17100100** is returned if an unknown error occurs. **17100101** is returned if the parameter is invalid. **17100102** is returned if the scheme configuration fails to be registered, which must be registered before the **Web** component is created.|
1055
1056### OH_ArkWebServiceWorker_SetSchemeHandler()
1057
1058```
1059bool OH_ArkWebServiceWorker_SetSchemeHandler(const char* scheme, ArkWeb_SchemeHandler* schemeHandler)
1060```
1061
1062**Description**
1063
1064Sets an **ArkWeb_SchemeHandler** for a specified scheme to intercept requests of the scheme type triggered by **ServiceWorker**. **SchemeHandler** should be set after **BrowserContext** is created.
1065
1066You can use **WebviewController.initializeWebEngine** to initialize **BrowserContext** without creating the **Web** component.
1067
1068**System capability**: SystemCapability.Web.Webview.Core
1069
1070**Since**: 12
1071
1072
1073**Parameters**
1074
1075| Name| Description|
1076| -- | -- |
1077| const char* scheme | Scheme to be intercepted.|
1078| [ArkWeb_SchemeHandler](capi-web-arkweb-schemehandler.md)* schemeHandler | **ArkWeb_SchemeHandler** of the scheme. Only requests triggered by **ServiceWorker** are notified through this **schemeHandler**.|
1079
1080**Returns**
1081
1082| Type| Description|
1083| -- | -- |
1084| bool | **true** is returned if the **SchemeHandler** is successfully set for the specified scheme. Otherwise, **false** is returned.|
1085
1086### OH_ArkWeb_SetSchemeHandler()
1087
1088```
1089bool OH_ArkWeb_SetSchemeHandler(const char* scheme, const char* webTag, ArkWeb_SchemeHandler* schemeHandler)
1090```
1091
1092**Description**
1093
1094Sets an **ArkWeb_SchemeHandler** to intercept requests of a specified scheme type. **SchemeHandler** should be set after **BrowserContext** is created.
1095
1096You can use **WebviewController.initializeWebEngine** to initialize **BrowserContext** without creating the **Web** component.
1097
1098**System capability**: SystemCapability.Web.Webview.Core
1099
1100**Since**: 12
1101
1102
1103**Parameters**
1104
1105| Name| Description|
1106| -- | -- |
1107| const char* scheme | Scheme to be intercepted.|
1108| const char* webTag | Tag that uniquely identifies a **Web** component. Ensure that it is unique.|
1109| [ArkWeb_SchemeHandler](capi-web-arkweb-schemehandler.md)* schemeHandler | **ArkWeb_SchemeHandler** of the scheme. Only requests triggered from the specified web are notified through this **SchemeHandler**.|
1110
1111**Returns**
1112
1113| Type| Description|
1114| -- | -- |
1115| bool | **true** is returned if the **SchemeHandler** is successfully set for the specified scheme. Otherwise, **false** is returned.|
1116
1117### OH_ArkWebServiceWorker_ClearSchemeHandlers()
1118
1119```
1120int32_t OH_ArkWebServiceWorker_ClearSchemeHandlers()
1121```
1122
1123**Description**
1124
1125Clears the **SchemeHandler** registered for **ServiceWorker**.
1126
1127**System capability**: SystemCapability.Web.Webview.Core
1128
1129**Since**: 12
1130
1131**Returns**
1132
1133| Type| Description|
1134| -- | -- |
1135| int32_t | **0** is returned if the operation is successful.|
1136
1137### OH_ArkWeb_ClearSchemeHandlers()
1138
1139```
1140int32_t OH_ArkWeb_ClearSchemeHandlers(const char* webTag)
1141```
1142
1143**Description**
1144
1145Clears the **SchemeHandler** registered for the specified **Web** component.
1146
1147**System capability**: SystemCapability.Web.Webview.Core
1148
1149**Since**: 12
1150
1151
1152**Parameters**
1153
1154| Name| Description|
1155| -- | -- |
1156| const char* webTag | Tag that uniquely identifies a **Web** component. Ensure that it is unique.|
1157
1158**Returns**
1159
1160| Type| Description|
1161| -- | -- |
1162| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1163
1164### OH_ArkWeb_CreateSchemeHandler()
1165
1166```
1167void OH_ArkWeb_CreateSchemeHandler(ArkWeb_SchemeHandler** schemeHandler)
1168```
1169
1170**Description**
1171
1172Creates an **ArkWeb_SchemeHandler** object.
1173
1174**System capability**: SystemCapability.Web.Webview.Core
1175
1176**Since**: 12
1177
1178
1179**Parameters**
1180
1181| Name| Description|
1182| -- | -- |
1183| [ArkWeb_SchemeHandler](capi-web-arkweb-schemehandler.md)** schemeHandler | A created **ArkWeb_SchemeHandler**. You can use **OH_ArkWeb_DestoryschemeHandler** to destroy it when it is not needed.|
1184
1185### OH_ArkWeb_DestroySchemeHandler()
1186
1187```
1188void OH_ArkWeb_DestroySchemeHandler(ArkWeb_SchemeHandler* schemeHandler)
1189```
1190
1191**Description**
1192
1193Destroys an **ArkWeb_SchemeHandler** object.
1194
1195**System capability**: SystemCapability.Web.Webview.Core
1196
1197**Since**: 12
1198
1199
1200**Parameters**
1201
1202| Name| Description|
1203| -- | -- |
1204| [ArkWeb_SchemeHandler](capi-web-arkweb-schemehandler.md)* schemeHandler | The **ArkWeb_SchemeHandler** to be destroyed.|
1205
1206### OH_ArkWebSchemeHandler_SetUserData()
1207
1208```
1209int32_t OH_ArkWebSchemeHandler_SetUserData(ArkWeb_SchemeHandler* schemeHandler, void* userData)
1210```
1211
1212**Description**
1213
1214Sets user data to the **ArkWeb_SchemeHandler** object.
1215
1216**System capability**: SystemCapability.Web.Webview.Core
1217
1218**Since**: 12
1219
1220
1221**Parameters**
1222
1223| Name| Description|
1224| -- | -- |
1225| [ArkWeb_SchemeHandler](capi-web-arkweb-schemehandler.md)* schemeHandler | **ArkWeb_SchemeHandler**.|
1226| void* userData | User data to be set.|
1227
1228**Returns**
1229
1230| Type| Description|
1231| -- | -- |
1232| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1233
1234### OH_ArkWebSchemeHandler_GetUserData()
1235
1236```
1237void* OH_ArkWebSchemeHandler_GetUserData(const ArkWeb_SchemeHandler* schemeHandler)
1238```
1239
1240**Description**
1241
1242Obtains the user data from **ArkWeb_SchemeHandler**.
1243
1244**System capability**: SystemCapability.Web.Webview.Core
1245
1246**Since**: 12
1247
1248
1249**Parameters**
1250
1251| Name| Description|
1252| -- | -- |
1253| const [ArkWeb_SchemeHandler](capi-web-arkweb-schemehandler.md)* schemeHandler | **ArkWeb_SchemeHandler**.|
1254
1255**Returns**
1256
1257| Type| Description|
1258| -- | -- |
1259| void* | User data.|
1260
1261### OH_ArkWebSchemeHandler_SetOnRequestStart()
1262
1263```
1264int32_t OH_ArkWebSchemeHandler_SetOnRequestStart(ArkWeb_SchemeHandler* schemeHandler,ArkWeb_OnRequestStart onRequestStart)
1265```
1266
1267**Description**
1268
1269Sets an **OnRequestStart** callback for **SchemeHandler**.
1270
1271**System capability**: SystemCapability.Web.Webview.Core
1272
1273**Since**: 12
1274
1275
1276**Parameters**
1277
1278| Name| Description|
1279| -- | -- |
1280| [ArkWeb_SchemeHandler](capi-web-arkweb-schemehandler.md)* schemeHandler | **SchemeHandler** of the scheme.|
1281| [ArkWeb_OnRequestStart](#arkweb_onrequeststart) onRequestStart | The callback function **OnRequestStart**.|
1282
1283**Returns**
1284
1285| Type| Description|
1286| -- | -- |
1287| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1288
1289### OH_ArkWebSchemeHandler_SetOnRequestStop()
1290
1291```
1292int32_t OH_ArkWebSchemeHandler_SetOnRequestStop(ArkWeb_SchemeHandler* schemeHandler,ArkWeb_OnRequestStop onRequestStop)
1293```
1294
1295**Description**
1296
1297Sets an **OnRequestStop** callback for **SchemeHandler**.
1298
1299**System capability**: SystemCapability.Web.Webview.Core
1300
1301**Since**: 12
1302
1303
1304**Parameters**
1305
1306| Name| Description|
1307| -- | -- |
1308| [ArkWeb_SchemeHandler](capi-web-arkweb-schemehandler.md)* schemeHandler | **SchemeHandler** of the scheme.|
1309| [ArkWeb_OnRequestStop](#arkweb_onrequeststop) onRequestStop | The callback function **OnRequestStop**.|
1310
1311**Returns**
1312
1313| Type| Description|
1314| -- | -- |
1315| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1316
1317### OH_ArkWeb_CreateResponse()
1318
1319```
1320void OH_ArkWeb_CreateResponse(ArkWeb_Response** response)
1321```
1322
1323**Description**
1324
1325Creates an **ArkWeb_Response** object for the intercepted request.
1326
1327**System capability**: SystemCapability.Web.Webview.Core
1328
1329**Since**: 12
1330
1331
1332**Parameters**
1333
1334| Name| Description|
1335| -- | -- |
1336| [ArkWeb_Response](capi-web-arkweb-response.md)** response | A created **ArkWeb_Response**. Use **OH_ArkWeb_DestoryResponse** to destroy it when it is not required.|
1337
1338### OH_ArkWeb_DestroyResponse()
1339
1340```
1341void OH_ArkWeb_DestroyResponse(ArkWeb_Response* response)
1342```
1343
1344**Description**
1345
1346Destroys an **ArkWeb_Response** object.
1347
1348**System capability**: SystemCapability.Web.Webview.Core
1349
1350**Since**: 12
1351
1352**Parameters**
1353
1354| Name| Description|
1355| -- | -- |
1356| [ArkWeb_Response](capi-web-arkweb-response.md)* response | The **ArkWeb_Response** to be destroyed.|
1357
1358### OH_ArkWebResponse_SetUrl()
1359
1360```
1361int32_t OH_ArkWebResponse_SetUrl(ArkWeb_Response* response, const char* url)
1362```
1363
1364**Description**
1365
1366Sets a parsed URL that has been redirected or changed due to HSTS. After the setting, redirection is triggered.
1367
1368**System capability**: SystemCapability.Web.Webview.Core
1369
1370**Since**: 12
1371
1372
1373**Parameters**
1374
1375| Name| Description|
1376| -- | -- |
1377| [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1378| const char* url | Parsed URL.|
1379
1380**Returns**
1381
1382| Type| Description|
1383| -- | -- |
1384| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1385
1386### OH_ArkWebResponse_GetUrl()
1387
1388```
1389void OH_ArkWebResponse_GetUrl(const ArkWeb_Response* response, char** url)
1390```
1391
1392**Description**
1393
1394Obtains the parsed URL that has been redirected or changed due to HSTS.
1395
1396**System capability**: SystemCapability.Web.Webview.Core
1397
1398**Since**: 12
1399
1400
1401**Parameters**
1402
1403| Name| Description|
1404| -- | -- |
1405| const [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1406| char** url | Parsed URL.|
1407
1408### OH_ArkWebResponse_SetError()
1409
1410```
1411int32_t OH_ArkWebResponse_SetError(ArkWeb_Response* response, ArkWeb_NetError errorCode)
1412```
1413
1414**Description**
1415
1416Sets an error code for the **ArkWeb_Response** object.
1417
1418**System capability**: SystemCapability.Web.Webview.Core
1419
1420**Since**: 12
1421
1422
1423**Parameters**
1424
1425| Name| Description|
1426| -- | -- |
1427| [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1428| [ArkWeb_NetError](capi-arkweb-net-error-list-h.md#arkweb_neterror) errorCode | Error code of the failed request.|
1429
1430**Returns**
1431
1432| Type| Description|
1433| -- | -- |
1434| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1435
1436### OH_ArkWebResponse_GetError()
1437
1438```
1439ArkWeb_NetError OH_ArkWebResponse_GetError(const ArkWeb_Response* response)
1440```
1441
1442**Description**
1443
1444Obtains the error code of **ArkWeb_Response**.
1445
1446**System capability**: SystemCapability.Web.Webview.Core
1447
1448**Since**: 12
1449
1450
1451**Parameters**
1452
1453| Name                                | Description|
1454|-------------------------------------| -- |
1455| const [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1456
1457**Returns**
1458
1459| Type| Description|
1460| -- | -- |
1461| [ArkWeb_NetError](capi-arkweb-net-error-list-h.md#arkweb_neterror) | Error code of **ArkWeb_Response**.|
1462
1463### OH_ArkWebResponse_SetStatus()
1464
1465```
1466int32_t OH_ArkWebResponse_SetStatus(ArkWeb_Response* response, int status)
1467```
1468
1469**Description**
1470
1471Sets an HTTP status code for **ArkWeb_Response**.
1472
1473**System capability**: SystemCapability.Web.Webview.Core
1474
1475**Since**: 12
1476
1477
1478**Parameters**
1479
1480| Name| Description|
1481| -- | -- |
1482| [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1483| int status | HTTP status code of the request.|
1484
1485**Returns**
1486
1487| Type| Description|
1488| -- | -- |
1489| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1490
1491### OH_ArkWebResponse_GetStatus()
1492
1493```
1494int OH_ArkWebResponse_GetStatus(const ArkWeb_Response* response)
1495```
1496
1497**Description**
1498
1499Obtains the HTTP status code of **ArkWeb_Response**.
1500
1501**System capability**: SystemCapability.Web.Webview.Core
1502
1503**Since**: 12
1504
1505
1506**Parameters**
1507
1508| Name                                | Description|
1509|-------------------------------------| -- |
1510| const [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1511
1512**Returns**
1513
1514| Type| Description|
1515| -- | -- |
1516| int | HTTP status code of **ArkWeb_Response**. If **ArkWeb_Response** is invalid, the value is **-1**.|
1517
1518### OH_ArkWebResponse_SetStatusText()
1519
1520```
1521int32_t OH_ArkWebResponse_SetStatusText(ArkWeb_Response* response, const char* statusText)
1522```
1523
1524**Description**
1525
1526Sets a status text for **ArkWeb_Response**.
1527
1528**System capability**: SystemCapability.Web.Webview.Core
1529
1530**Since**: 12
1531
1532
1533**Parameters**
1534
1535| Name| Description|
1536| -- | -- |
1537| [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1538| const char* statusText | Status text of the request.|
1539
1540**Returns**
1541
1542| Type| Description|
1543| -- | -- |
1544| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1545
1546### OH_ArkWebResponse_GetStatusText()
1547
1548```
1549void OH_ArkWebResponse_GetStatusText(const ArkWeb_Response* response, char** statusText)
1550```
1551
1552**Description**
1553
1554Obtains the status text of **ArkWeb_Response**.
1555
1556**System capability**: SystemCapability.Web.Webview.Core
1557
1558**Since**: 12
1559
1560
1561**Parameters**
1562
1563| Name| Description|
1564| -- | -- |
1565| const [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1566| char** statusText | Status text of **ArkWeb_Response**. This function allocates memory for the **statusText** string. You need to release the string using **OH_ArkWeb_ReleaseString**.|
1567
1568### OH_ArkWebResponse_SetMimeType()
1569
1570```
1571int32_t OH_ArkWebResponse_SetMimeType(ArkWeb_Response* response, const char* mimeType)
1572```
1573
1574**Description**
1575
1576Sets a mime type for **ArkWeb_Response**.
1577
1578**System capability**: SystemCapability.Web.Webview.Core
1579
1580**Since**: 12
1581
1582
1583**Parameters**
1584
1585| Name| Description|
1586| -- | -- |
1587| [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1588| const char* mimeType | Mime type of the request.|
1589
1590**Returns**
1591
1592| Type| Description|
1593| -- | -- |
1594| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1595
1596### OH_ArkWebResponse_GetMimeType()
1597
1598```
1599void OH_ArkWebResponse_GetMimeType(const ArkWeb_Response* response, char** mimeType)
1600```
1601
1602**Description**
1603
1604Obtains the mime type of **ArkWeb_Response**.
1605
1606**System capability**: SystemCapability.Web.Webview.Core
1607
1608**Since**: 12
1609
1610
1611**Parameters**
1612
1613| Name| Description|
1614| -- | -- |
1615| const [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1616| char** mimeType | Mime type of **ArkWeb_Response**. This function allocates memory for the **mimeType** string. You need to release the string using **OH_ArkWeb_ReleaseString**.|
1617
1618### OH_ArkWebResponse_SetCharset()
1619
1620```
1621int32_t OH_ArkWebResponse_SetCharset(ArkWeb_Response* response, const char* charset)
1622```
1623
1624**Description**
1625
1626Sets a character set for **ArkWeb_Response**.
1627
1628**System capability**: SystemCapability.Web.Webview.Core
1629
1630**Since**: 12
1631
1632
1633**Parameters**
1634
1635| Name| Description|
1636| -- | -- |
1637| [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1638| const char* charset | Character set of the request.|
1639
1640**Returns**
1641
1642| Type| Description|
1643| -- | -- |
1644| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1645
1646### OH_ArkWebResponse_GetCharset()
1647
1648```
1649void OH_ArkWebResponse_GetCharset(const ArkWeb_Response* response, char** charset)
1650```
1651
1652**Description**
1653
1654Obtains the character set of **ArkWeb_Response**.
1655
1656**System capability**: SystemCapability.Web.Webview.Core
1657
1658**Since**: 12
1659
1660
1661**Parameters**
1662
1663| Name| Description|
1664| -- | -- |
1665| const [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1666| char** charset | Character set of **ArkWeb_Response**. This function allocates memory for the **charset** string. You need to release the string using **OH_ArkWeb_ReleaseString**.|
1667
1668### OH_ArkWebResponse_SetHeaderByName()
1669
1670```
1671int32_t OH_ArkWebResponse_SetHeaderByName(ArkWeb_Response* response,const char* name,const char* value,bool overwrite)
1672```
1673
1674**Description**
1675
1676Sets a header for **ArkWeb_Response**.
1677
1678**System capability**: SystemCapability.Web.Webview.Core
1679
1680**Since**: 12
1681
1682
1683**Parameters**
1684
1685| Name| Description|
1686| -- | -- |
1687| [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1688| const char* name | Name of the header.|
1689| const char* value | Value of the header.|
1690| bool overwrite | Whether to overwrite the existing header. The value **true** means to overwrite the existing header, and **false** means the opposite.|
1691
1692**Returns**
1693
1694| Type| Description|
1695| -- | -- |
1696| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1697
1698### OH_ArkWebResponse_GetHeaderByName()
1699
1700```
1701void OH_ArkWebResponse_GetHeaderByName(const ArkWeb_Response* response, const char* name, char** value)
1702```
1703
1704**Description**
1705
1706Obtains the header from **ArkWeb_Response**.
1707
1708**System capability**: SystemCapability.Web.Webview.Core
1709
1710**Since**: 12
1711
1712
1713**Parameters**
1714
1715| Name| Description|
1716| -- | -- |
1717| const [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response**.|
1718| const char* name | Name of the header.|
1719| char** value | Value of the header. This function allocates memory for the **value **string. You need to release the string using **OH_ArkWeb_ReleaseString**.|
1720
1721### OH_ArkWebResourceHandler_Destroy()
1722
1723```
1724int32_t OH_ArkWebResourceHandler_Destroy(const ArkWeb_ResourceHandler* resourceHandler)
1725```
1726
1727**Description**
1728
1729Destroys an **ArkWeb_ResourceHandler** object.
1730
1731**System capability**: SystemCapability.Web.Webview.Core
1732
1733**Since**: 12
1734
1735
1736**Parameters**
1737
1738| Name                                              | Description|
1739|---------------------------------------------------| -- |
1740| const [ArkWeb_ResourceHandler](capi-web-arkweb-resourcehandler.md)* resourceHandler | **ArkWeb_ResourceHandler**.|
1741
1742**Returns**
1743
1744| Type| Description|
1745| -- | -- |
1746| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1747
1748### OH_ArkWebResourceHandler_DidReceiveResponse()
1749
1750```
1751int32_t OH_ArkWebResourceHandler_DidReceiveResponse(const ArkWeb_ResourceHandler* resourceHandler,const ArkWeb_Response* response)
1752```
1753
1754**Description**
1755
1756Sends a response header to the intercepted request.
1757
1758**System capability**: SystemCapability.Web.Webview.Core
1759
1760**Since**: 12
1761
1762
1763**Parameters**
1764
1765| Name| Description|
1766| -- | -- |
1767| const [ArkWeb_ResourceHandler](capi-web-arkweb-resourcehandler.md)* resourceHandler | **ArkWeb_ResourceHandler** of the request.|
1768| const [ArkWeb_Response](capi-web-arkweb-response.md)* response | **ArkWeb_Response** of the intercepted request.|
1769
1770**Returns**
1771
1772| Type| Description|
1773| -- | -- |
1774| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1775
1776### OH_ArkWebResourceHandler_DidReceiveData()
1777
1778```
1779int32_t OH_ArkWebResourceHandler_DidReceiveData(const ArkWeb_ResourceHandler* resourceHandler,const uint8_t* buffer,int64_t bufLen)
1780```
1781
1782**Description**
1783
1784Sends a response body to the intercepted request.
1785
1786**System capability**: SystemCapability.Web.Webview.Core
1787
1788**Since**: 12
1789
1790
1791**Parameters**
1792
1793| Name| Description|
1794| -- | -- |
1795| const [ArkWeb_ResourceHandler](capi-web-arkweb-resourcehandler.md)* resourceHandler | **ArkWeb_ResourceHandler** of the request.|
1796| const uint8_t* buffer | Buffer data to be sent.|
1797| int64_t bufLen | Buffer size.|
1798
1799**Returns**
1800
1801| Type| Description|
1802| -- | -- |
1803| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1804
1805### OH_ArkWebResourceHandler_DidFinish()
1806
1807```
1808int32_t OH_ArkWebResourceHandler_DidFinish(const ArkWeb_ResourceHandler* resourceHandler)
1809```
1810
1811**Description**
1812
1813Notifies the ArkWeb kernel that the intercepted request has been finished and that no more data is available.
1814
1815**System capability**: SystemCapability.Web.Webview.Core
1816
1817**Since**: 12
1818
1819
1820**Parameters**
1821
1822| Name| Description|
1823| -- | -- |
1824| const [ArkWeb_ResourceHandler](capi-web-arkweb-resourcehandler.md)* resourceHandler | **ArkWeb_ResourceHandler** of the request.|
1825
1826**Returns**
1827
1828| Type| Description|
1829| -- | -- |
1830| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1831
1832### OH_ArkWebResourceHandler_DidFailWithError()
1833
1834```
1835int32_t OH_ArkWebResourceHandler_DidFailWithError(const ArkWeb_ResourceHandler* resourceHandler,ArkWeb_NetError errorCode)
1836```
1837
1838**Description**
1839
1840Notifies the ArkWeb kernel that the intercepted request fails.
1841
1842**System capability**: SystemCapability.Web.Webview.Core
1843
1844**Since**: 12
1845
1846
1847**Parameters**
1848
1849| Name| Description|
1850| -- | -- |
1851| const [ArkWeb_ResourceHandler](capi-web-arkweb-resourcehandler.md)* resourceHandler | **ArkWeb_ResourceHandler** of the request.|
1852| [ArkWeb_NetError](capi-arkweb-net-error-list-h.md#arkweb_neterror) errorCode | Error code of the request. For details, see [arkweb_net_error_list.h](capi-arkweb-net-error-list-h.md).|
1853
1854**Returns**
1855
1856| Type| Description|
1857| -- | -- |
1858| int32_t | **0** is returned when the operation is successful; **17100101** is returned when the parameter is invalid.|
1859
1860### OH_ArkWeb_ReleaseString()
1861
1862```
1863void OH_ArkWeb_ReleaseString(char* string)
1864```
1865
1866**Description**
1867
1868Releases the string created by NDK APIs.
1869
1870**System capability**: SystemCapability.Web.Webview.Core
1871
1872**Since**: 12
1873
1874
1875**Parameters**
1876
1877| Name| Description|
1878| -- | -- |
1879| char* string | String to be released.|
1880
1881### OH_ArkWeb_ReleaseByteArray()
1882
1883```
1884void OH_ArkWeb_ReleaseByteArray(uint8_t* byteArray)
1885```
1886
1887**Description**
1888
1889Releases the byte array created by NDK APIs.
1890
1891**System capability**: SystemCapability.Web.Webview.Core
1892
1893**Since**: 12
1894
1895
1896**Parameters**
1897
1898| Name| Description|
1899| -- | -- |
1900| uint8_t* byteArray | Byte array to be released.|
1901