From 10715e11dd355c8e78adb73ac36263ba951e29f0 Mon Sep 17 00:00:00 2001 From: "wudefeng@huawei.com" Date: Tue, 5 Jul 2022 21:19:08 +0800 Subject: [PATCH 1/2] add onInterceptRequest api Signed-off-by: wudefeng@huawei.com --- api/@internal/component/ets/web.d.ts | 57 ++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) mode change 100755 => 100644 api/@internal/component/ets/web.d.ts diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts old mode 100755 new mode 100644 index fa6391e1f4..d59b174261 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -533,6 +533,54 @@ declare class WebResourceRequest { * @since 8 */ getResponseCode(): number; + + /** + * Sets the response data. + * @param data the response data. + * + * @since 9 + */ + setResponseData(data: string); + + /** + * Sets the response encoding. + * @param encoding the response encoding. + * + * @since 9 + */ + setResponseEncoding(encoding: string); + + /** + * Sets the response MIME type. + * @param mimeType the response MIME type. + * + * @since 9 + */ + setResponseMimeType(mimeType: string); + + /** + * Sets the reason message. + * @param reason the reason message. + * + * @since 9 + */ + setReasonMessage(reason: string); + + /** + * Sets the response headers. + * @param header the response headers. + * + * @since 9 + */ + setResponseHeader(header: Array
); + + /** + * Gets the response code. + * @param code the response code. + * + * @since 9 + */ + setResponseCode(code: number); } /** @@ -1317,6 +1365,15 @@ declare class WebAttribute extends CommonMethod { * @since 9 */ onHttpAuthRequest(callback: (event?: { result: WebHttpAuthResult }) => boolean): WebAttribute; + + /** + * Triggered when the resouces loading is intercepted. + * @param callback The triggered callback when the resouces loading is intercepted. + * + * @return If the response value is null, the Web will continue to load the resouces. Otherwise, the response value will be used + * @since 9 + */ + onInterceptRequest(callback: (event?: { request: WebResourceRequest}) => WebResourceResponse): WebAttribute; } declare const Web: WebInterface; -- Gitee From 15d66deb132ee3fead1e891eb1418392409df33d Mon Sep 17 00:00:00 2001 From: "wudefeng@huawei.com" Date: Thu, 7 Jul 2022 09:43:11 +0800 Subject: [PATCH 2/2] modify interface of setResponseCode notes Signed-off-by: wudefeng@huawei.com --- api/@internal/component/ets/web.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts index d59b174261..f2b0c93a3a 100644 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -575,7 +575,7 @@ declare class WebResourceRequest { setResponseHeader(header: Array
); /** - * Gets the response code. + * Sets the response code. * @param code the response code. * * @since 9 -- Gitee