10826e83eSopenharmony_ci/*
20826e83eSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
30826e83eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
40826e83eSopenharmony_ci * you may not use this file except in compliance with the License.
50826e83eSopenharmony_ci * You may obtain a copy of the License at
60826e83eSopenharmony_ci *
70826e83eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
80826e83eSopenharmony_ci *
90826e83eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
100826e83eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
110826e83eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120826e83eSopenharmony_ci * See the License for the specific language governing permissions and
130826e83eSopenharmony_ci * limitations under the License.
140826e83eSopenharmony_ci */
150826e83eSopenharmony_ci
160826e83eSopenharmony_ci/**
170826e83eSopenharmony_ci * @addtogroup Web
180826e83eSopenharmony_ci * @{
190826e83eSopenharmony_ci *
200826e83eSopenharmony_ci * @brief Provides APIs to intercept the request from ArkWeb.
210826e83eSopenharmony_ci * @since 12
220826e83eSopenharmony_ci */
230826e83eSopenharmony_ci/**
240826e83eSopenharmony_ci * @file arkweb_scheme_handler.h
250826e83eSopenharmony_ci *
260826e83eSopenharmony_ci * @brief Declares the APIs to intercept the request from ArkWeb.
270826e83eSopenharmony_ci * @library libohweb.so
280826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
290826e83eSopenharmony_ci * @since 12
300826e83eSopenharmony_ci */
310826e83eSopenharmony_ci#ifndef ARKWEB_SCHEME_HANDLER_H
320826e83eSopenharmony_ci#define ARKWEB_SCHEME_HANDLER_H
330826e83eSopenharmony_ci
340826e83eSopenharmony_ci#include <cstdint>
350826e83eSopenharmony_ci
360826e83eSopenharmony_ci#include "arkweb_error_code.h"
370826e83eSopenharmony_ci#include "arkweb_net_error_list.h"
380826e83eSopenharmony_ci
390826e83eSopenharmony_ci#ifdef __cplusplus
400826e83eSopenharmony_ciextern "C" {
410826e83eSopenharmony_ci#endif
420826e83eSopenharmony_ci
430826e83eSopenharmony_ci/*
440826e83eSopenharmony_ci * @brief Configuration information for custom schemes.
450826e83eSopenharmony_ci *
460826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
470826e83eSopenharmony_ci * @since 12
480826e83eSopenharmony_ci */
490826e83eSopenharmony_citypedef enum ArkWeb_CustomSchemeOption {
500826e83eSopenharmony_ci    OH_ARKWEB_SCHEME_OPTION_NONE = 0,
510826e83eSopenharmony_ci
520826e83eSopenharmony_ci    /*
530826e83eSopenharmony_ci     * @brief If ARKWEB_SCHEME_OPTION_STANDARD is set the scheme will be handled as a standard scheme. The standard
540826e83eSopenharmony_ci     *        schemes needs to comply with the URL normalization and parsing rules defined in Section 3.1 of RFC 1738,
550826e83eSopenharmony_ci     *        which can be found in the http://www.ietf.org/rfc/rfc1738.txt.
560826e83eSopenharmony_ci     *
570826e83eSopenharmony_ci     * @syscap SystemCapability.Web.Webview.Core
580826e83eSopenharmony_ci     * @since 12
590826e83eSopenharmony_ci     */
600826e83eSopenharmony_ci    ARKWEB_SCHEME_OPTION_STANDARD = 1 << 0,
610826e83eSopenharmony_ci
620826e83eSopenharmony_ci    /*
630826e83eSopenharmony_ci     * @brief If ARKWEB_SCHEME_OPTION_LOCAL is set, the same security rules as those applied to the "file" URL will be
640826e83eSopenharmony_ci     *        used to handle the scheme.
650826e83eSopenharmony_ci     *
660826e83eSopenharmony_ci     * @syscap SystemCapability.Web.Webview.Core
670826e83eSopenharmony_ci     * @since 12
680826e83eSopenharmony_ci     */
690826e83eSopenharmony_ci    ARKWEB_SCHEME_OPTION_LOCAL = 1 << 1,
700826e83eSopenharmony_ci
710826e83eSopenharmony_ci    /*
720826e83eSopenharmony_ci     * @brief If ARKWEB_SCHEME_OPTION_DISPLAY_ISOLATED is set, then the scheme can only be displayed from other content
730826e83eSopenharmony_ci     *        hosted using the same scheme.
740826e83eSopenharmony_ci     *
750826e83eSopenharmony_ci     * @syscap SystemCapability.Web.Webview.Core
760826e83eSopenharmony_ci     * @since 12
770826e83eSopenharmony_ci     */
780826e83eSopenharmony_ci    ARKWEB_SCHEME_OPTION_DISPLAY_ISOLATED = 1 << 2,
790826e83eSopenharmony_ci
800826e83eSopenharmony_ci    /*
810826e83eSopenharmony_ci     * @brief If ARKWEB_SCHEME_OPTION_SECURE is set, the same security rules as those applied to the "https" URL will be
820826e83eSopenharmony_ci     *        used to handle the scheme.
830826e83eSopenharmony_ci     *
840826e83eSopenharmony_ci     * @syscap SystemCapability.Web.Webview.Core
850826e83eSopenharmony_ci     * @since 12
860826e83eSopenharmony_ci     */
870826e83eSopenharmony_ci    ARKWEB_SCHEME_OPTION_SECURE = 1 << 3,
880826e83eSopenharmony_ci
890826e83eSopenharmony_ci    /*
900826e83eSopenharmony_ci     * @brief If ARKWEB_SCHEME_OPTION_CORS_ENABLED is set, then the scheme can be sent CORS requests. In most case this
910826e83eSopenharmony_ci     *        value should be set when ARKWEB_SCHEME_OPTION_STANDARD is set.
920826e83eSopenharmony_ci     *
930826e83eSopenharmony_ci     * @syscap SystemCapability.Web.Webview.Core
940826e83eSopenharmony_ci     * @since 12
950826e83eSopenharmony_ci     */
960826e83eSopenharmony_ci    ARKWEB_SCHEME_OPTION_CORS_ENABLED = 1 << 4,
970826e83eSopenharmony_ci
980826e83eSopenharmony_ci    /*
990826e83eSopenharmony_ci     * @brief If ARKWEB_SCHEME_OPTION_CSP_BYPASSING is set, then this scheme can bypass Content Security Policy (CSP)
1000826e83eSopenharmony_ci     *        checks. In most cases, this value should not be set when ARKWEB_SCHEME_OPTION_STANDARD is set.
1010826e83eSopenharmony_ci     *
1020826e83eSopenharmony_ci     * @syscap SystemCapability.Web.Webview.Core
1030826e83eSopenharmony_ci     * @since 12
1040826e83eSopenharmony_ci     */
1050826e83eSopenharmony_ci    ARKWEB_SCHEME_OPTION_CSP_BYPASSING = 1 << 5,
1060826e83eSopenharmony_ci
1070826e83eSopenharmony_ci    /*
1080826e83eSopenharmony_ci     * @brief If ARKWEB_SCHEME_OPTION_FETCH_ENABLED is set, then this scheme can perform FETCH API requests.
1090826e83eSopenharmony_ci     *
1100826e83eSopenharmony_ci     * @syscap SystemCapability.Web.Webview.Core
1110826e83eSopenharmony_ci     * @since 12
1120826e83eSopenharmony_ci     */
1130826e83eSopenharmony_ci    ARKWEB_SCHEME_OPTION_FETCH_ENABLED = 1 << 6,
1140826e83eSopenharmony_ci
1150826e83eSopenharmony_ci    /*
1160826e83eSopenharmony_ci     * @brief If ARKWEB_SCHEME_OPTION_CODE_CACHE_ENABLED is set, then the js of this scheme can generate code cache.
1170826e83eSopenharmony_ci     *
1180826e83eSopenharmony_ci     * @syscap SystemCapability.Web.Webview.Core
1190826e83eSopenharmony_ci     * @since 12
1200826e83eSopenharmony_ci     */
1210826e83eSopenharmony_ci    ARKWEB_SCHEME_OPTION_CODE_CACHE_ENABLED = 1 << 7,
1220826e83eSopenharmony_ci} ArkWeb_CustomSchemeOption;
1230826e83eSopenharmony_ci
1240826e83eSopenharmony_ci/*
1250826e83eSopenharmony_ci * @brief  This class is used to intercept requests for a specified scheme.
1260826e83eSopenharmony_ci *
1270826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
1280826e83eSopenharmony_ci * @since 12
1290826e83eSopenharmony_ci */
1300826e83eSopenharmony_citypedef struct ArkWeb_SchemeHandler_ ArkWeb_SchemeHandler;
1310826e83eSopenharmony_ci
1320826e83eSopenharmony_ci/*
1330826e83eSopenharmony_ci * @brief Used to intercept url requests. Response headers and body can be sent through ArkWeb_ResourceHandler.
1340826e83eSopenharmony_ci *
1350826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
1360826e83eSopenharmony_ci * @since 12
1370826e83eSopenharmony_ci */
1380826e83eSopenharmony_citypedef struct ArkWeb_ResourceHandler_ ArkWeb_ResourceHandler;
1390826e83eSopenharmony_ci
1400826e83eSopenharmony_ci/*
1410826e83eSopenharmony_ci * @brief The response of the intercepted request.
1420826e83eSopenharmony_ci *
1430826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
1440826e83eSopenharmony_ci * @since 12
1450826e83eSopenharmony_ci */
1460826e83eSopenharmony_citypedef struct ArkWeb_Response_ ArkWeb_Response;
1470826e83eSopenharmony_ci
1480826e83eSopenharmony_ci/*
1490826e83eSopenharmony_ci * @brief The info of the request. You can obtain the requested URL, method, post data, and other information through
1500826e83eSopenharmony_ci *        OH_ArkWeb_ResourceRequest.
1510826e83eSopenharmony_ci *
1520826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
1530826e83eSopenharmony_ci * @since 12
1540826e83eSopenharmony_ci */
1550826e83eSopenharmony_citypedef struct ArkWeb_ResourceRequest_ ArkWeb_ResourceRequest;
1560826e83eSopenharmony_ci
1570826e83eSopenharmony_ci/*
1580826e83eSopenharmony_ci * @brief The request headers of the request.
1590826e83eSopenharmony_ci *
1600826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
1610826e83eSopenharmony_ci * @since 12
1620826e83eSopenharmony_ci */
1630826e83eSopenharmony_citypedef struct ArkWeb_RequestHeaderList_ ArkWeb_RequestHeaderList;
1640826e83eSopenharmony_ci
1650826e83eSopenharmony_ci/*
1660826e83eSopenharmony_ci * @brief The http body of the request. Use OH_ArkWebHttpBodyStream_* interface to read the body.
1670826e83eSopenharmony_ci *
1680826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
1690826e83eSopenharmony_ci * @since 12
1700826e83eSopenharmony_ci */
1710826e83eSopenharmony_citypedef struct ArkWeb_HttpBodyStream_ ArkWeb_HttpBodyStream;
1720826e83eSopenharmony_ci
1730826e83eSopenharmony_ci
1740826e83eSopenharmony_ci/*
1750826e83eSopenharmony_ci * @brief Callback for handling the request. This will called on the IO thread. should not use resourceHandler in the
1760826e83eSopenharmony_ci *        function.
1770826e83eSopenharmony_ci * @param schemeHandler The ArkWeb_SchemeHandler.
1780826e83eSopenharmony_ci * @param resourceRequest Obtain request's information through this.
1790826e83eSopenharmony_ci * @param resourceHandler The ArkWeb_ResourceHandler for the request. It should not be used if intercept is set to
1800826e83eSopenharmony_ci *                        false.
1810826e83eSopenharmony_ci * @param intercept If true will intercept the request, if false otherwise.
1820826e83eSopenharmony_ci *
1830826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
1840826e83eSopenharmony_ci * @since 12
1850826e83eSopenharmony_ci */
1860826e83eSopenharmony_citypedef void (*ArkWeb_OnRequestStart)(const ArkWeb_SchemeHandler* schemeHandler,
1870826e83eSopenharmony_ci                                      ArkWeb_ResourceRequest* resourceRequest,
1880826e83eSopenharmony_ci                                      const ArkWeb_ResourceHandler* resourceHandler,
1890826e83eSopenharmony_ci                                      bool* intercept);
1900826e83eSopenharmony_ci
1910826e83eSopenharmony_ci/*
1920826e83eSopenharmony_ci * @brief Callback when the request is completed. This will called on the IO thread.
1930826e83eSopenharmony_ci *        Should destory the resourceRequest by ArkWeb_ResourceRequest_Destroy and use ArkWeb_ResourceHandler_Destroy
1940826e83eSopenharmony_ci *        destroy the ArkWeb_ResourceHandler received in ArkWeb_OnRequestStart.
1950826e83eSopenharmony_ci * @param schemeHandler The ArkWeb_SchemeHandler.
1960826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
1970826e83eSopenharmony_ci *
1980826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
1990826e83eSopenharmony_ci * @since 12
2000826e83eSopenharmony_ci */
2010826e83eSopenharmony_citypedef void (*ArkWeb_OnRequestStop)(const ArkWeb_SchemeHandler* schemeHandler,
2020826e83eSopenharmony_ci                                     const ArkWeb_ResourceRequest* resourceRequest);
2030826e83eSopenharmony_ci
2040826e83eSopenharmony_ci/*
2050826e83eSopenharmony_ci * @brief Callback when the read operation done.
2060826e83eSopenharmony_ci * @param httpBodyStream The ArkWeb_HttpBodyStream.
2070826e83eSopenharmony_ci * @param buffer The buffer to receive data.
2080826e83eSopenharmony_ci * @param bytesRead Callback after OH_ArkWebHttpBodyStream_Read. bytesRead greater than 0 means that the buffer is
2090826e83eSopenharmony_ci *                  filled with data of bytesRead size. Caller can read from the buffer, and if
2100826e83eSopenharmony_ci *                  OH_ArkWebHttpBodyStream_IsEOF is false, caller can continue to read the remaining data.
2110826e83eSopenharmony_ci *
2120826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
2130826e83eSopenharmony_ci * @since 12
2140826e83eSopenharmony_ci */
2150826e83eSopenharmony_citypedef void (*ArkWeb_HttpBodyStreamReadCallback)(const ArkWeb_HttpBodyStream* httpBodyStream,
2160826e83eSopenharmony_ci                                                  uint8_t* buffer,
2170826e83eSopenharmony_ci                                                  int bytesRead);
2180826e83eSopenharmony_ci
2190826e83eSopenharmony_ci/*
2200826e83eSopenharmony_ci * @brief  Callback when the init operation done.
2210826e83eSopenharmony_ci * @param httpBodyStream The ArkWeb_HttpBodyStream.
2220826e83eSopenharmony_ci * @param result ARKWEB_NET_OK on success otherwise refer to ARKWEB_NET_ERROR.
2230826e83eSopenharmony_ci *
2240826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
2250826e83eSopenharmony_ci * @since 12
2260826e83eSopenharmony_ci */
2270826e83eSopenharmony_citypedef void (*ArkWeb_HttpBodyStreamInitCallback)(const ArkWeb_HttpBodyStream* httpBodyStream, ArkWeb_NetError result);
2280826e83eSopenharmony_ci
2290826e83eSopenharmony_ci/*
2300826e83eSopenharmony_ci * @brief Destroy the ArkWeb_RequestHeaderList.
2310826e83eSopenharmony_ci * @param requestHeaderList The ArkWeb_RequestHeaderList to be destroyed.
2320826e83eSopenharmony_ci *
2330826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
2340826e83eSopenharmony_ci * @since 12
2350826e83eSopenharmony_ci */
2360826e83eSopenharmony_civoid OH_ArkWebRequestHeaderList_Destroy(ArkWeb_RequestHeaderList* requestHeaderList);
2370826e83eSopenharmony_ci
2380826e83eSopenharmony_ci/*
2390826e83eSopenharmony_ci * @brief Get the request headers size.
2400826e83eSopenharmony_ci * @param requestHeaderList The list of request header.
2410826e83eSopenharmony_ci * @return The size of request headers. -1 if requestHeaderList is invalid.
2420826e83eSopenharmony_ci *
2430826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
2440826e83eSopenharmony_ci * @since 12
2450826e83eSopenharmony_ci */
2460826e83eSopenharmony_ciint32_t OH_ArkWebRequestHeaderList_GetSize(const ArkWeb_RequestHeaderList* requestHeaderList);
2470826e83eSopenharmony_ci
2480826e83eSopenharmony_ci/*
2490826e83eSopenharmony_ci * @brief Get the specified request header.
2500826e83eSopenharmony_ci * @param requestHeaderList The list of request header.
2510826e83eSopenharmony_ci * @param index The index of request header.
2520826e83eSopenharmony_ci * @param key The header key. Caller must release the string by OH_ArkWeb_ReleaseString.
2530826e83eSopenharmony_ci * @param value The header value. Caller must release the string by OH_ArkWeb_ReleaseString.
2540826e83eSopenharmony_ci *
2550826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
2560826e83eSopenharmony_ci * @since 12
2570826e83eSopenharmony_ci */
2580826e83eSopenharmony_civoid OH_ArkWebRequestHeaderList_GetHeader(const ArkWeb_RequestHeaderList* requestHeaderList,
2590826e83eSopenharmony_ci                                          int32_t index,
2600826e83eSopenharmony_ci                                          char** key,
2610826e83eSopenharmony_ci                                          char** value);
2620826e83eSopenharmony_ci
2630826e83eSopenharmony_ci/*
2640826e83eSopenharmony_ci * @brief Set a user data to ArkWeb_ResourceRequest.
2650826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
2660826e83eSopenharmony_ci * @param userData The user data to set.
2670826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
2680826e83eSopenharmony_ci *
2690826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
2700826e83eSopenharmony_ci * @since 12
2710826e83eSopenharmony_ci */
2720826e83eSopenharmony_ciint32_t OH_ArkWebResourceRequest_SetUserData(ArkWeb_ResourceRequest* resourceRequest, void* userData);
2730826e83eSopenharmony_ci
2740826e83eSopenharmony_ci/*
2750826e83eSopenharmony_ci * @brief Get the user data from ArkWeb_ResourceRequest.
2760826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
2770826e83eSopenharmony_ci * @return The set user data.
2780826e83eSopenharmony_ci *
2790826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
2800826e83eSopenharmony_ci * @since 12
2810826e83eSopenharmony_ci */
2820826e83eSopenharmony_civoid* OH_ArkWebResourceRequest_GetUserData(const ArkWeb_ResourceRequest* resourceRequest);
2830826e83eSopenharmony_ci
2840826e83eSopenharmony_ci/*
2850826e83eSopenharmony_ci * @brief Get the method of request.
2860826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
2870826e83eSopenharmony_ci * @param method The request's http method. This function will allocate memory for the method string and caller must
2880826e83eSopenharmony_ci *               release the string by OH_ArkWeb_ReleaseString.
2890826e83eSopenharmony_ci *
2900826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
2910826e83eSopenharmony_ci * @since 12
2920826e83eSopenharmony_ci */
2930826e83eSopenharmony_civoid OH_ArkWebResourceRequest_GetMethod(const ArkWeb_ResourceRequest* resourceRequest, char** method);
2940826e83eSopenharmony_ci
2950826e83eSopenharmony_ci/*
2960826e83eSopenharmony_ci * @brief Get the url of request.
2970826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
2980826e83eSopenharmony_ci * @param url The request's url. This function will allocate memory for the url string and caller must release the
2990826e83eSopenharmony_ci *            string by OH_ArkWeb_ReleaseString.
3000826e83eSopenharmony_ci *
3010826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
3020826e83eSopenharmony_ci * @since 12
3030826e83eSopenharmony_ci */
3040826e83eSopenharmony_civoid OH_ArkWebResourceRequest_GetUrl(const ArkWeb_ResourceRequest* resourceRequest, char** url);
3050826e83eSopenharmony_ci
3060826e83eSopenharmony_ci/*
3070826e83eSopenharmony_ci * @brief Create a ArkWeb_HttpBodyStream which used to read the http body.
3080826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
3090826e83eSopenharmony_ci * @param httpBodyStream The request's http body. This function will allocate memory for the http body stream and
3100826e83eSopenharmony_ci *                       caller must release the httpBodyStream by OH_ArkWebResourceRequest_DestroyHttpBodyStream.
3110826e83eSopenharmony_ci *
3120826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
3130826e83eSopenharmony_ci * @since 12
3140826e83eSopenharmony_ci */
3150826e83eSopenharmony_civoid OH_ArkWebResourceRequest_GetHttpBodyStream(const ArkWeb_ResourceRequest* resourceRequest,
3160826e83eSopenharmony_ci                                                ArkWeb_HttpBodyStream** httpBodyStream);
3170826e83eSopenharmony_ci
3180826e83eSopenharmony_ci/*
3190826e83eSopenharmony_ci * @brief Destroy the http body stream.
3200826e83eSopenharmony_ci * @param httpBodyStream The httpBodyStream to be destroyed.
3210826e83eSopenharmony_ci *
3220826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
3230826e83eSopenharmony_ci * @since 12
3240826e83eSopenharmony_ci */
3250826e83eSopenharmony_civoid OH_ArkWebResourceRequest_DestroyHttpBodyStream(ArkWeb_HttpBodyStream* httpBodyStream);
3260826e83eSopenharmony_ci
3270826e83eSopenharmony_ci/*
3280826e83eSopenharmony_ci * @brief Get the resource type of request.
3290826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
3300826e83eSopenharmony_ci * @return The resource type of request. -1 if resourceRequest is invalid.
3310826e83eSopenharmony_ci *
3320826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
3330826e83eSopenharmony_ci * @since 12
3340826e83eSopenharmony_ci */
3350826e83eSopenharmony_ciint32_t OH_ArkWebResourceRequest_GetResourceType(const ArkWeb_ResourceRequest* resourceRequest);
3360826e83eSopenharmony_ci
3370826e83eSopenharmony_ci/*
3380826e83eSopenharmony_ci * @brief Get the url of frame which trigger this request.
3390826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
3400826e83eSopenharmony_ci * @param frameUrl The url of frame which trigger this request. This function will allocate memory for the url string
3410826e83eSopenharmony_ci *            and caller must release the string by OH_ArkWeb_ReleaseString.
3420826e83eSopenharmony_ci *
3430826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
3440826e83eSopenharmony_ci * @since 12
3450826e83eSopenharmony_ci */
3460826e83eSopenharmony_civoid OH_ArkWebResourceRequest_GetFrameUrl(const ArkWeb_ResourceRequest* resourceRequest, char** frameUrl);
3470826e83eSopenharmony_ci
3480826e83eSopenharmony_ci/*
3490826e83eSopenharmony_ci * @brief Set a user data to ArkWeb_HttpBodyStream.
3500826e83eSopenharmony_ci * @param httpBodyStream The ArkWeb_HttpBodyStream.
3510826e83eSopenharmony_ci * @param userData The user data to set.
3520826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
3530826e83eSopenharmony_ci *
3540826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
3550826e83eSopenharmony_ci * @since 12
3560826e83eSopenharmony_ci */
3570826e83eSopenharmony_ciint32_t OH_ArkWebHttpBodyStream_SetUserData(ArkWeb_HttpBodyStream* httpBodyStream, void* userData);
3580826e83eSopenharmony_ci
3590826e83eSopenharmony_ci/*
3600826e83eSopenharmony_ci * @brief Get the user data from ArkWeb_HttpBodyStream.
3610826e83eSopenharmony_ci * @param httpBodyStream The ArkWeb_HttpBodyStream.
3620826e83eSopenharmony_ci * @return The set user data.
3630826e83eSopenharmony_ci *
3640826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
3650826e83eSopenharmony_ci * @since 12
3660826e83eSopenharmony_ci */
3670826e83eSopenharmony_civoid* OH_ArkWebHttpBodyStream_GetUserData(const ArkWeb_HttpBodyStream* httpBodyStream);
3680826e83eSopenharmony_ci
3690826e83eSopenharmony_ci/*
3700826e83eSopenharmony_ci * @brief Set the callback for OH_ArkWebHttpBodyStream_Read, the result of OH_ArkWebHttpBodyStream_Read will be
3710826e83eSopenharmony_ci *        notified to caller through the readCallback. The callback will runs in the same thread as
3720826e83eSopenharmony_ci *        OH_ArkWebHttpBodyStream_Read.
3730826e83eSopenharmony_ci * @param httpBodyStream The ArkWeb_HttpBodyStream.
3740826e83eSopenharmony_ci * @param readCallback The callback of read function.
3750826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
3760826e83eSopenharmony_ci *
3770826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
3780826e83eSopenharmony_ci * @since 12
3790826e83eSopenharmony_ci */
3800826e83eSopenharmony_ciint32_t OH_ArkWebHttpBodyStream_SetReadCallback(ArkWeb_HttpBodyStream* httpBodyStream,
3810826e83eSopenharmony_ci                                                ArkWeb_HttpBodyStreamReadCallback readCallback);
3820826e83eSopenharmony_ci
3830826e83eSopenharmony_ci/*
3840826e83eSopenharmony_ci * @brief Init the http body stream. This function must be called before calling any other functions.
3850826e83eSopenharmony_ci * @param httpBodyStream The ArkWeb_HttpBodyStream.
3860826e83eSopenharmony_ci * @param initCallback The callback of init.
3870826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
3880826e83eSopenharmony_ci *
3890826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
3900826e83eSopenharmony_ci * @since 12
3910826e83eSopenharmony_ci */
3920826e83eSopenharmony_ciint32_t OH_ArkWebHttpBodyStream_Init(ArkWeb_HttpBodyStream* httpBodyStream,
3930826e83eSopenharmony_ci                                     ArkWeb_HttpBodyStreamInitCallback initCallback);
3940826e83eSopenharmony_ci
3950826e83eSopenharmony_ci/*
3960826e83eSopenharmony_ci * @brief Read the http body to the buffer. The buffer must be larger than the bufLen. We will be reading data from a
3970826e83eSopenharmony_ci *        worker thread to the buffer, so should not use the buffer in other threads before the callback to avoid
3980826e83eSopenharmony_ci *        concurrency issues.
3990826e83eSopenharmony_ci * @param httpBodyStream The ArkWeb_HttpBodyStream.
4000826e83eSopenharmony_ci * @param buffer The buffer to receive data.
4010826e83eSopenharmony_ci * @param bufLen The size of bytes to read.
4020826e83eSopenharmony_ci *
4030826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
4040826e83eSopenharmony_ci * @since 12
4050826e83eSopenharmony_ci */
4060826e83eSopenharmony_civoid OH_ArkWebHttpBodyStream_Read(const ArkWeb_HttpBodyStream* httpBodyStream, uint8_t* buffer, int bufLen);
4070826e83eSopenharmony_ci
4080826e83eSopenharmony_ci/*
4090826e83eSopenharmony_ci * @brief Get the total size of the data stream.
4100826e83eSopenharmony_ci *        When data is chunked or httpBodyStream is invalid, always return zero.
4110826e83eSopenharmony_ci * @param httpBodyStream The ArkWeb_HttpBodyStream.
4120826e83eSopenharmony_ci * @return The size of data stream.
4130826e83eSopenharmony_ci *
4140826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
4150826e83eSopenharmony_ci * @since 12
4160826e83eSopenharmony_ci */
4170826e83eSopenharmony_ciuint64_t OH_ArkWebHttpBodyStream_GetSize(const ArkWeb_HttpBodyStream* httpBodyStream);
4180826e83eSopenharmony_ci
4190826e83eSopenharmony_ci/*
4200826e83eSopenharmony_ci * @brief Get the current position of the data stream.
4210826e83eSopenharmony_ci * @param httpBodyStream The ArkWeb_HttpBodyStream.
4220826e83eSopenharmony_ci * @return The current position of data stream. 0 if httpBodyStream is invalid.
4230826e83eSopenharmony_ci *
4240826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
4250826e83eSopenharmony_ci * @since 12
4260826e83eSopenharmony_ci */
4270826e83eSopenharmony_ciuint64_t OH_ArkWebHttpBodyStream_GetPosition(const ArkWeb_HttpBodyStream* httpBodyStream);
4280826e83eSopenharmony_ci
4290826e83eSopenharmony_ci/*
4300826e83eSopenharmony_ci * @brief Get if the data stream is chunked.
4310826e83eSopenharmony_ci * @param httpBodyStream The ArkWeb_HttpBodyStream.
4320826e83eSopenharmony_ci * @return True if is chunked; false otherwise.
4330826e83eSopenharmony_ci *
4340826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
4350826e83eSopenharmony_ci * @since 12
4360826e83eSopenharmony_ci */
4370826e83eSopenharmony_cibool OH_ArkWebHttpBodyStream_IsChunked(const ArkWeb_HttpBodyStream* httpBodyStream);
4380826e83eSopenharmony_ci
4390826e83eSopenharmony_ci
4400826e83eSopenharmony_ci/*
4410826e83eSopenharmony_ci * @brief Returns true if all data has been consumed from this upload data stream. For chunked uploads, returns false
4420826e83eSopenharmony_ci *        until the first read attempt.
4430826e83eSopenharmony_ci * @param httpBodyStream The ArkWeb_HttpBodyStream.
4440826e83eSopenharmony_ci * @return True if all data has been consumed; false otherwise.
4450826e83eSopenharmony_ci *
4460826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
4470826e83eSopenharmony_ci * @since 12
4480826e83eSopenharmony_ci */
4490826e83eSopenharmony_cibool OH_ArkWebHttpBodyStream_IsEof(const ArkWeb_HttpBodyStream* httpBodyStream);
4500826e83eSopenharmony_ci
4510826e83eSopenharmony_ci/*
4520826e83eSopenharmony_ci * @brief Returns true if the upload data in the stream is entirely in memory, and all read requests will succeed
4530826e83eSopenharmony_ci *        synchronously. Expected to return false for chunked requests.
4540826e83eSopenharmony_ci * @param httpBodyStream The ArkWeb_HttpBodyStream.
4550826e83eSopenharmony_ci * @return True if the upload data is in memory; false otherwise.
4560826e83eSopenharmony_ci *
4570826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
4580826e83eSopenharmony_ci * @since 12
4590826e83eSopenharmony_ci */
4600826e83eSopenharmony_cibool OH_ArkWebHttpBodyStream_IsInMemory(const ArkWeb_HttpBodyStream* httpBodyStream);
4610826e83eSopenharmony_ci
4620826e83eSopenharmony_ci/*
4630826e83eSopenharmony_ci * @brief Destroy the ArkWeb_ResourceRequest.
4640826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
4650826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
4660826e83eSopenharmony_ci *
4670826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
4680826e83eSopenharmony_ci * @since 12
4690826e83eSopenharmony_ci */
4700826e83eSopenharmony_ciint32_t OH_ArkWebResourceRequest_Destroy(const ArkWeb_ResourceRequest* resourceRequest);
4710826e83eSopenharmony_ci
4720826e83eSopenharmony_ci/*
4730826e83eSopenharmony_ci * @brief Get the referrer of request.
4740826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
4750826e83eSopenharmony_ci * @param referrer The request's referrer. This function will allocate memory for the referrer string and caller
4760826e83eSopenharmony_ci *                 must release the string by OH_ArkWeb_ReleaseString.
4770826e83eSopenharmony_ci *
4780826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
4790826e83eSopenharmony_ci * @since 12
4800826e83eSopenharmony_ci */
4810826e83eSopenharmony_civoid OH_ArkWebResourceRequest_GetReferrer(const ArkWeb_ResourceRequest* resourceRequest, char** referrer);
4820826e83eSopenharmony_ci
4830826e83eSopenharmony_ci/*
4840826e83eSopenharmony_ci * @brief Get the OH_ArkWeb_RequestHeaderList of the request.
4850826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
4860826e83eSopenharmony_ci * @param requestHeaderList The RequestHeaderList of request.
4870826e83eSopenharmony_ci *
4880826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
4890826e83eSopenharmony_ci * @since 12
4900826e83eSopenharmony_ci */
4910826e83eSopenharmony_civoid OH_ArkWebResourceRequest_GetRequestHeaders(const ArkWeb_ResourceRequest* resourceRequest,
4920826e83eSopenharmony_ci                                                ArkWeb_RequestHeaderList** requestHeaderList);
4930826e83eSopenharmony_ci
4940826e83eSopenharmony_ci/*
4950826e83eSopenharmony_ci * @brief Get if this is a redirect request.
4960826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
4970826e83eSopenharmony_ci * @return True if this is a redirect; false otherwise.
4980826e83eSopenharmony_ci *
4990826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
5000826e83eSopenharmony_ci * @since 12
5010826e83eSopenharmony_ci */
5020826e83eSopenharmony_cibool OH_ArkWebResourceRequest_IsRedirect(const ArkWeb_ResourceRequest* resourceRequest);
5030826e83eSopenharmony_ci
5040826e83eSopenharmony_ci/*
5050826e83eSopenharmony_ci * @brief Get if this is a request from main frame.
5060826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
5070826e83eSopenharmony_ci * @return True if this is from main frame; false otherwise.
5080826e83eSopenharmony_ci *
5090826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
5100826e83eSopenharmony_ci * @since 12
5110826e83eSopenharmony_ci */
5120826e83eSopenharmony_cibool OH_ArkWebResourceRequest_IsMainFrame(const ArkWeb_ResourceRequest* resourceRequest);
5130826e83eSopenharmony_ci
5140826e83eSopenharmony_ci/*
5150826e83eSopenharmony_ci * @brief Get if this is a request is triggered by user gesutre.
5160826e83eSopenharmony_ci * @param resourceRequest The ArkWeb_ResourceRequest.
5170826e83eSopenharmony_ci * @return True if this is triggered by user gesture; false otherwise.
5180826e83eSopenharmony_ci *
5190826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
5200826e83eSopenharmony_ci * @since 12
5210826e83eSopenharmony_ci */
5220826e83eSopenharmony_cibool OH_ArkWebResourceRequest_HasGesture(const ArkWeb_ResourceRequest* resourceRequest);
5230826e83eSopenharmony_ci
5240826e83eSopenharmony_ci/*
5250826e83eSopenharmony_ci * @brief Register custom scheme to the ArkWeb. Should not be called for built-in HTTP, HTTPS, FILE, FTP, ABOUT and
5260826e83eSopenharmony_ci *        DATA schemes. This function should be called on main thread.
5270826e83eSopenharmony_ci * @param scheme The scheme to regist.
5280826e83eSopenharmony_ci * @param option The configuration of the scheme.
5290826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
5300826e83eSopenharmony_ci *
5310826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
5320826e83eSopenharmony_ci * @since 12
5330826e83eSopenharmony_ci */
5340826e83eSopenharmony_ciint32_t OH_ArkWeb_RegisterCustomSchemes(const char* scheme, int32_t option);
5350826e83eSopenharmony_ci
5360826e83eSopenharmony_ci/*
5370826e83eSopenharmony_ci * @brief Set a ArkWeb_SchemeHandler for a specific scheme to intercept requests of that scheme type.
5380826e83eSopenharmony_ci *        SchemeHandler should be set after the BrowserContext created.
5390826e83eSopenharmony_ci *        Use WebviewController.initializeWebEngine to initialize the BrowserContext without create a ArkWeb.
5400826e83eSopenharmony_ci *
5410826e83eSopenharmony_ci * @param scheme Scheme that need to be intercepted.
5420826e83eSopenharmony_ci * @param schemeHandler The SchemeHandler for the scheme. Only requests triggered by ServiceWorker will be notified
5430826e83eSopenharmony_ci *                      through this handler.
5440826e83eSopenharmony_ci * @return Return true if set SchemeHandler for specific scheme successful, return false otherwise.
5450826e83eSopenharmony_ci *
5460826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
5470826e83eSopenharmony_ci * @since 12
5480826e83eSopenharmony_ci */
5490826e83eSopenharmony_cibool OH_ArkWebServiceWorker_SetSchemeHandler(const char* scheme, ArkWeb_SchemeHandler* schemeHandler);
5500826e83eSopenharmony_ci
5510826e83eSopenharmony_ci/*
5520826e83eSopenharmony_ci * @brief Set a ArkWeb_SchemeHandler for a specific scheme to intercept requests of that scheme type.
5530826e83eSopenharmony_ci *        SchemeHandler should be set after the BrowserContext created.
5540826e83eSopenharmony_ci *        Use WebviewController.initializeWebEngine to initialize the BrowserContext without create a ArkWeb.
5550826e83eSopenharmony_ci *
5560826e83eSopenharmony_ci * @param scheme Scheme that need to be intercepted.
5570826e83eSopenharmony_ci * @param webTag The name of the web component.
5580826e83eSopenharmony_ci * @param schemeHandler The SchemeHandler for the scheme. Only requests triggered from the specified web will be
5590826e83eSopenharmony_ci *                      notified through this handler.
5600826e83eSopenharmony_ci * @return Return true if set SchemeHandler for specific scheme successful, return false otherwise.
5610826e83eSopenharmony_ci *
5620826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
5630826e83eSopenharmony_ci * @since 12
5640826e83eSopenharmony_ci */
5650826e83eSopenharmony_cibool OH_ArkWeb_SetSchemeHandler(const char* scheme, const char* webTag, ArkWeb_SchemeHandler* schemeHandler);
5660826e83eSopenharmony_ci
5670826e83eSopenharmony_ci/*
5680826e83eSopenharmony_ci * @brief Clear the handler registered on the specified web for service worker.
5690826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
5700826e83eSopenharmony_ci *
5710826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
5720826e83eSopenharmony_ci * @since 12
5730826e83eSopenharmony_ci */
5740826e83eSopenharmony_ciint32_t OH_ArkWebServiceWorker_ClearSchemeHandlers();
5750826e83eSopenharmony_ci
5760826e83eSopenharmony_ci/*
5770826e83eSopenharmony_ci * @brief Clear the handler registered on the specified web.
5780826e83eSopenharmony_ci * @param webTag The name of the web component.
5790826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
5800826e83eSopenharmony_ci *
5810826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
5820826e83eSopenharmony_ci * @since 12
5830826e83eSopenharmony_ci */
5840826e83eSopenharmony_ciint32_t OH_ArkWeb_ClearSchemeHandlers(const char* webTag);
5850826e83eSopenharmony_ci
5860826e83eSopenharmony_ci/*
5870826e83eSopenharmony_ci * @brief Create a SchemeHandler.
5880826e83eSopenharmony_ci * @param schemeHandler Return the created SchemeHandler. Use OH_ArkWeb_DestroySchemeHandler destroy it when donn't
5890826e83eSopenharmony_ci *                      need it.
5900826e83eSopenharmony_ci *
5910826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
5920826e83eSopenharmony_ci * @since 12
5930826e83eSopenharmony_ci */
5940826e83eSopenharmony_civoid OH_ArkWeb_CreateSchemeHandler(ArkWeb_SchemeHandler** schemeHandler);
5950826e83eSopenharmony_ci
5960826e83eSopenharmony_ci/*
5970826e83eSopenharmony_ci * @brief Destroy a SchemeHandler.
5980826e83eSopenharmony_ci * @param The ArkWeb_SchemeHandler to be destroy.
5990826e83eSopenharmony_ci *
6000826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
6010826e83eSopenharmony_ci * @since 12
6020826e83eSopenharmony_ci */
6030826e83eSopenharmony_civoid OH_ArkWeb_DestroySchemeHandler(ArkWeb_SchemeHandler* schemeHandler);
6040826e83eSopenharmony_ci
6050826e83eSopenharmony_ci/*
6060826e83eSopenharmony_ci * @brief Set a user data to ArkWeb_SchemeHandler.
6070826e83eSopenharmony_ci * @param schemeHandler The ArkWeb_SchemeHandler.
6080826e83eSopenharmony_ci * @param userData The user data to set.
6090826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
6100826e83eSopenharmony_ci *
6110826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
6120826e83eSopenharmony_ci * @since 12
6130826e83eSopenharmony_ci */
6140826e83eSopenharmony_ciint32_t OH_ArkWebSchemeHandler_SetUserData(ArkWeb_SchemeHandler* schemeHandler, void* userData);
6150826e83eSopenharmony_ci
6160826e83eSopenharmony_ci/*
6170826e83eSopenharmony_ci * @brief Get the user data from ArkWeb_SchemeHandler.
6180826e83eSopenharmony_ci * @param schemeHandler The ArkWeb_SchemeHandler.
6190826e83eSopenharmony_ci * @return The set user data.
6200826e83eSopenharmony_ci *
6210826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
6220826e83eSopenharmony_ci * @since 12
6230826e83eSopenharmony_ci */
6240826e83eSopenharmony_civoid* OH_ArkWebSchemeHandler_GetUserData(const ArkWeb_SchemeHandler* schemeHandler);
6250826e83eSopenharmony_ci
6260826e83eSopenharmony_ci/*
6270826e83eSopenharmony_ci * @brief Set the OnRequestStart callback for SchemeHandler.
6280826e83eSopenharmony_ci * @param schemeHandler The SchemeHandler for the scheme.
6290826e83eSopenharmony_ci * @param onRequestStart The OnRequestStart callback.
6300826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
6310826e83eSopenharmony_ci *
6320826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
6330826e83eSopenharmony_ci * @since 12
6340826e83eSopenharmony_ci */
6350826e83eSopenharmony_ciint32_t OH_ArkWebSchemeHandler_SetOnRequestStart(ArkWeb_SchemeHandler* schemeHandler,
6360826e83eSopenharmony_ci                                                 ArkWeb_OnRequestStart onRequestStart);
6370826e83eSopenharmony_ci
6380826e83eSopenharmony_ci/*
6390826e83eSopenharmony_ci * @brief Set the OnRequestStop callback for SchemeHandler.
6400826e83eSopenharmony_ci * @param schemeHandler The SchemeHandler for the scheme.
6410826e83eSopenharmony_ci * @param onRequestStop The OnRequestStop callback.
6420826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
6430826e83eSopenharmony_ci *
6440826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
6450826e83eSopenharmony_ci * @since 12
6460826e83eSopenharmony_ci */
6470826e83eSopenharmony_ciint32_t OH_ArkWebSchemeHandler_SetOnRequestStop(ArkWeb_SchemeHandler* schemeHandler,
6480826e83eSopenharmony_ci                                                ArkWeb_OnRequestStop onRequestStop);
6490826e83eSopenharmony_ci
6500826e83eSopenharmony_ci/*
6510826e83eSopenharmony_ci * @brief Create a Response for a request.
6520826e83eSopenharmony_ci * @param Return the created Response. Use OH_ArkWeb_DestroyResponse to destroy when donn't need it.
6530826e83eSopenharmony_ci *
6540826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
6550826e83eSopenharmony_ci * @since 12
6560826e83eSopenharmony_ci */
6570826e83eSopenharmony_civoid OH_ArkWeb_CreateResponse(ArkWeb_Response** response);
6580826e83eSopenharmony_ci
6590826e83eSopenharmony_ci/*
6600826e83eSopenharmony_ci * @brief Destroy the Reponse.
6610826e83eSopenharmony_ci * @param response The Response needs destroy.
6620826e83eSopenharmony_ci *
6630826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
6640826e83eSopenharmony_ci * @since 12
6650826e83eSopenharmony_ci */
6660826e83eSopenharmony_civoid OH_ArkWeb_DestroyResponse(ArkWeb_Response* response);
6670826e83eSopenharmony_ci
6680826e83eSopenharmony_ci/*
6690826e83eSopenharmony_ci * @brief Set the resolved URL after redirects or changed as a result of HSTS.
6700826e83eSopenharmony_ci * @param response The ArkWeb_Response.
6710826e83eSopenharmony_ci * @param url The resolved URL.
6720826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
6730826e83eSopenharmony_ci *
6740826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
6750826e83eSopenharmony_ci * @since 12
6760826e83eSopenharmony_ci */
6770826e83eSopenharmony_ciint32_t OH_ArkWebResponse_SetUrl(ArkWeb_Response* response, const char* url);
6780826e83eSopenharmony_ci
6790826e83eSopenharmony_ci/*
6800826e83eSopenharmony_ci * @brief Get the resolved URL after redirects or changed as a result of HSTS.
6810826e83eSopenharmony_ci * @param response The ArkWeb_Response.
6820826e83eSopenharmony_ci * @param url The resolved URL.
6830826e83eSopenharmony_ci *
6840826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
6850826e83eSopenharmony_ci * @since 12
6860826e83eSopenharmony_ci */
6870826e83eSopenharmony_civoid OH_ArkWebResponse_GetUrl(const ArkWeb_Response* response, char** url);
6880826e83eSopenharmony_ci
6890826e83eSopenharmony_ci/*
6900826e83eSopenharmony_ci * @brief Set a error code to ArkWeb_Response.
6910826e83eSopenharmony_ci * @param response The ArkWeb_Response.
6920826e83eSopenharmony_ci * @param errorCode The error code for the failed request.
6930826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
6940826e83eSopenharmony_ci *
6950826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
6960826e83eSopenharmony_ci * @since 12
6970826e83eSopenharmony_ci */
6980826e83eSopenharmony_ciint32_t OH_ArkWebResponse_SetError(ArkWeb_Response* response, ArkWeb_NetError errorCode);
6990826e83eSopenharmony_ci
7000826e83eSopenharmony_ci/*
7010826e83eSopenharmony_ci * @brief Get the response's error code.
7020826e83eSopenharmony_ci * @param response The ArkWeb_Response.
7030826e83eSopenharmony_ci * @return The response's error code.
7040826e83eSopenharmony_ci *
7050826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
7060826e83eSopenharmony_ci * @since 12
7070826e83eSopenharmony_ci */
7080826e83eSopenharmony_ciArkWeb_NetError OH_ArkWebResponse_GetError(const ArkWeb_Response* response);
7090826e83eSopenharmony_ci
7100826e83eSopenharmony_ci/*
7110826e83eSopenharmony_ci * @brief Set a status code to ArkWebResponse.
7120826e83eSopenharmony_ci * @param response The ArkWeb_Response.
7130826e83eSopenharmony_ci * @param status The http status code for the request.
7140826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
7150826e83eSopenharmony_ci *
7160826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
7170826e83eSopenharmony_ci * @since 12
7180826e83eSopenharmony_ci */
7190826e83eSopenharmony_ciint32_t OH_ArkWebResponse_SetStatus(ArkWeb_Response* response, int status);
7200826e83eSopenharmony_ci
7210826e83eSopenharmony_ci/*
7220826e83eSopenharmony_ci * @brief Get the response's status code.
7230826e83eSopenharmony_ci * @param response The ArkWeb_Response.
7240826e83eSopenharmony_ci * @return The response's http status code. -1 if response is invalid.
7250826e83eSopenharmony_ci *
7260826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
7270826e83eSopenharmony_ci * @since 12
7280826e83eSopenharmony_ci */
7290826e83eSopenharmony_ciint OH_ArkWebResponse_GetStatus(const ArkWeb_Response* response);
7300826e83eSopenharmony_ci
7310826e83eSopenharmony_ci/*
7320826e83eSopenharmony_ci * @brief Set a status text to ArkWebResponse.
7330826e83eSopenharmony_ci * @param response The ArkWeb_Response.
7340826e83eSopenharmony_ci * @param statusText The status text for the request.
7350826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
7360826e83eSopenharmony_ci *
7370826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
7380826e83eSopenharmony_ci * @since 12
7390826e83eSopenharmony_ci */
7400826e83eSopenharmony_ciint32_t OH_ArkWebResponse_SetStatusText(ArkWeb_Response* response, const char* statusText);
7410826e83eSopenharmony_ci
7420826e83eSopenharmony_ci/*
7430826e83eSopenharmony_ci * @brief Get the response's status text.
7440826e83eSopenharmony_ci * @param response The ArkWeb_Response.
7450826e83eSopenharmony_ci * @param statusText Return the response's statusText. This function will allocate memory for the statusText string and
7460826e83eSopenharmony_ci *                   caller must release the string by OH_ArkWeb_ReleaseString.
7470826e83eSopenharmony_ci *
7480826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
7490826e83eSopenharmony_ci * @since 12
7500826e83eSopenharmony_ci */
7510826e83eSopenharmony_civoid OH_ArkWebResponse_GetStatusText(const ArkWeb_Response* response, char** statusText);
7520826e83eSopenharmony_ci
7530826e83eSopenharmony_ci/*
7540826e83eSopenharmony_ci * @brief Set mime type to ArkWebResponse.
7550826e83eSopenharmony_ci * @param response The ArkWeb_Response.
7560826e83eSopenharmony_ci * @param mimeType The mime type for the request.
7570826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
7580826e83eSopenharmony_ci *
7590826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
7600826e83eSopenharmony_ci * @since 12
7610826e83eSopenharmony_ci */
7620826e83eSopenharmony_ciint32_t OH_ArkWebResponse_SetMimeType(ArkWeb_Response* response, const char* mimeType);
7630826e83eSopenharmony_ci
7640826e83eSopenharmony_ci/*
7650826e83eSopenharmony_ci * @brief Get the response's mime type.
7660826e83eSopenharmony_ci * @param response The ArkWeb_Response.
7670826e83eSopenharmony_ci * @param mimeType Return the response's mime type. This function will allocate memory for the mime type string and
7680826e83eSopenharmony_ci *                 caller must release the string by OH_ArkWeb_ReleaseString.
7690826e83eSopenharmony_ci *
7700826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
7710826e83eSopenharmony_ci * @since 12
7720826e83eSopenharmony_ci */
7730826e83eSopenharmony_civoid OH_ArkWebResponse_GetMimeType(const ArkWeb_Response* response, char** mimeType);
7740826e83eSopenharmony_ci
7750826e83eSopenharmony_ci/*
7760826e83eSopenharmony_ci * @brief Set charset to ArkWeb_Response.
7770826e83eSopenharmony_ci * @param response The ArkWeb_Response.
7780826e83eSopenharmony_ci * @param charset The charset for the request.
7790826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
7800826e83eSopenharmony_ci *
7810826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
7820826e83eSopenharmony_ci * @since 12
7830826e83eSopenharmony_ci */
7840826e83eSopenharmony_ciint32_t OH_ArkWebResponse_SetCharset(ArkWeb_Response* response, const char* charset);
7850826e83eSopenharmony_ci
7860826e83eSopenharmony_ci/*
7870826e83eSopenharmony_ci * @brief Get the response's charset.
7880826e83eSopenharmony_ci * @param response The ArkWeb_Response.
7890826e83eSopenharmony_ci * @param charset Return the response's charset. This function will allocate memory for the charset string and caller
7900826e83eSopenharmony_ci *                must release the string by OH_ArkWeb_ReleaseString.
7910826e83eSopenharmony_ci *
7920826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
7930826e83eSopenharmony_ci * @since 12
7940826e83eSopenharmony_ci */
7950826e83eSopenharmony_civoid OH_ArkWebResponse_GetCharset(const ArkWeb_Response* response, char** charset);
7960826e83eSopenharmony_ci
7970826e83eSopenharmony_ci/*
7980826e83eSopenharmony_ci * @brief Set a header to ArkWeb_Response.
7990826e83eSopenharmony_ci * @param response The ArkWeb_Response.
8000826e83eSopenharmony_ci * @param name The name of the header.
8010826e83eSopenharmony_ci * @param value The value of the header.
8020826e83eSopenharmony_ci * @bool overwirte If true will overwrite the exsits header, if false otherwise.
8030826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
8040826e83eSopenharmony_ci *
8050826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
8060826e83eSopenharmony_ci * @since 12
8070826e83eSopenharmony_ci */
8080826e83eSopenharmony_ciint32_t OH_ArkWebResponse_SetHeaderByName(ArkWeb_Response* response,
8090826e83eSopenharmony_ci                                          const char* name,
8100826e83eSopenharmony_ci                                          const char* value,
8110826e83eSopenharmony_ci                                          bool overwrite);
8120826e83eSopenharmony_ci
8130826e83eSopenharmony_ci/*
8140826e83eSopenharmony_ci * @brief Get the header from the response.
8150826e83eSopenharmony_ci * @param response The ArkWeb_Response.
8160826e83eSopenharmony_ci * @param name The name of the header.
8170826e83eSopenharmony_ci * @param value Return the header's value. This function will allocate memory for the value string and caller must
8180826e83eSopenharmony_ci *              release the string by OH_ArkWeb_ReleaseString.
8190826e83eSopenharmony_ci *
8200826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
8210826e83eSopenharmony_ci * @since 12
8220826e83eSopenharmony_ci */
8230826e83eSopenharmony_civoid OH_ArkWebResponse_GetHeaderByName(const ArkWeb_Response* response, const char* name, char** value);
8240826e83eSopenharmony_ci
8250826e83eSopenharmony_ci/*
8260826e83eSopenharmony_ci * @brief Destroy the ArkWeb_ResourceHandler.
8270826e83eSopenharmony_ci * @param resourceHandler The ArkWeb_ResourceHandler.
8280826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
8290826e83eSopenharmony_ci *
8300826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
8310826e83eSopenharmony_ci * @since 12
8320826e83eSopenharmony_ci */
8330826e83eSopenharmony_ciint32_t OH_ArkWebResourceHandler_Destroy(const ArkWeb_ResourceHandler* resourceHandler);
8340826e83eSopenharmony_ci
8350826e83eSopenharmony_ci/*
8360826e83eSopenharmony_ci * @brief Pass response headers to intercepted requests.
8370826e83eSopenharmony_ci * @param resourceHandler The ArkWeb_ResourceHandler for the request.
8380826e83eSopenharmony_ci * @param response The ArkWeb_Response for the intercepting requests.
8390826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
8400826e83eSopenharmony_ci *
8410826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
8420826e83eSopenharmony_ci * @since 12
8430826e83eSopenharmony_ci */
8440826e83eSopenharmony_ciint32_t OH_ArkWebResourceHandler_DidReceiveResponse(const ArkWeb_ResourceHandler* resourceHandler,
8450826e83eSopenharmony_ci                                                    const ArkWeb_Response* response);
8460826e83eSopenharmony_ci
8470826e83eSopenharmony_ci/*
8480826e83eSopenharmony_ci * @brief Pass response body data to intercepted requests.
8490826e83eSopenharmony_ci * @param resourceHandler The ArkWeb_ResourceHandler for the request.
8500826e83eSopenharmony_ci * @param buffer Buffer data to send.
8510826e83eSopenharmony_ci * @param bufLen The size of buffer.
8520826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
8530826e83eSopenharmony_ci *
8540826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
8550826e83eSopenharmony_ci * @since 12
8560826e83eSopenharmony_ci */
8570826e83eSopenharmony_ciint32_t OH_ArkWebResourceHandler_DidReceiveData(const ArkWeb_ResourceHandler* resourceHandler,
8580826e83eSopenharmony_ci                                                const uint8_t* buffer,
8590826e83eSopenharmony_ci                                                int64_t bufLen);
8600826e83eSopenharmony_ci
8610826e83eSopenharmony_ci/*
8620826e83eSopenharmony_ci * @brief Notify the ArkWeb that this request should be finished and there is no more data available.
8630826e83eSopenharmony_ci * @param resourceHandler The ArkWeb_ResourceHandler for the request.
8640826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
8650826e83eSopenharmony_ci *
8660826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
8670826e83eSopenharmony_ci * @since 12
8680826e83eSopenharmony_ci */
8690826e83eSopenharmony_ciint32_t OH_ArkWebResourceHandler_DidFinish(const ArkWeb_ResourceHandler* resourceHandler);
8700826e83eSopenharmony_ci
8710826e83eSopenharmony_ci/*
8720826e83eSopenharmony_ci * @brief Notify the ArkWeb that this request should be failed.
8730826e83eSopenharmony_ci * @param resourceHandler The ArkWeb_ResourceHandler for the request.
8740826e83eSopenharmony_ci * @param errorCode The error code for this request. refer to arkweb_net_error_list.h
8750826e83eSopenharmony_ci * @return 0 if success; otherwise if fail. refer to arkweb_error_code.h.
8760826e83eSopenharmony_ci *
8770826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
8780826e83eSopenharmony_ci * @since 12
8790826e83eSopenharmony_ci */
8800826e83eSopenharmony_ciint32_t OH_ArkWebResourceHandler_DidFailWithError(const ArkWeb_ResourceHandler* resourceHandler,
8810826e83eSopenharmony_ci                                                  ArkWeb_NetError errorCode);
8820826e83eSopenharmony_ci
8830826e83eSopenharmony_ci/*
8840826e83eSopenharmony_ci * @brief Release the string acquired by native function.
8850826e83eSopenharmony_ci * @param string The string to be released.
8860826e83eSopenharmony_ci *
8870826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
8880826e83eSopenharmony_ci * @since 12
8890826e83eSopenharmony_ci */
8900826e83eSopenharmony_civoid OH_ArkWeb_ReleaseString(char* string);
8910826e83eSopenharmony_ci
8920826e83eSopenharmony_ci/*
8930826e83eSopenharmony_ci * @brief Release the byte array acquired by native function.
8940826e83eSopenharmony_ci * @param byteArray The byte array to be released.
8950826e83eSopenharmony_ci *
8960826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
8970826e83eSopenharmony_ci * @since 12
8980826e83eSopenharmony_ci */
8990826e83eSopenharmony_civoid OH_ArkWeb_ReleaseByteArray(uint8_t* byteArray);
9000826e83eSopenharmony_ci
9010826e83eSopenharmony_ciint32_t OH_ArkWebSchemeHandler_SetFromEts(ArkWeb_SchemeHandler* schemeHandler,
9020826e83eSopenharmony_ci                                          bool fromEts);
9030826e83eSopenharmony_ci
9040826e83eSopenharmony_ci#ifdef __cplusplus
9050826e83eSopenharmony_ci};
9060826e83eSopenharmony_ci#endif
9070826e83eSopenharmony_ci#endif // ARKWEB_SCHEME_HANDLER_H
908