diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 index 6bd6457a2fed846cc10698666fa1268219f1bee1..d565b667212016cd3633190b21b6664c34a0654d 100644 --- a/entry/build-profile.json5 +++ b/entry/build-profile.json5 @@ -13,7 +13,7 @@ "arkOptions": { "obfuscation": { "ruleOptions": { - "enable": false, + "enable": true, "files": [ "./obfuscation-rules.txt" ] diff --git a/entry/src/main/ets/Interceptors/LocalResourceInterceptor/model/LocalResourceModel.ets b/entry/src/main/ets/Interceptors/LocalResourceInterceptor/model/LocalResourceModel.ets index 133dded6e5b6ed2d49d20b6fe89a9143733ee83e..6e0a62238b7e247b7f05c6b811a36be249b3cb05 100644 --- a/entry/src/main/ets/Interceptors/LocalResourceInterceptor/model/LocalResourceModel.ets +++ b/entry/src/main/ets/Interceptors/LocalResourceInterceptor/model/LocalResourceModel.ets @@ -87,9 +87,12 @@ export class LocalResourceModel { } const rawfileName = this.schemeMap.get(key); - const mimeType = this.mimeTypeMap.get(rawfileName!); + if (!rawfileName) { + return null; // Invalid mapping, allow original request + } - if (!rawfileName || !mimeType) { + const mimeType = this.mimeTypeMap.get(rawfileName); + if (!mimeType) { return null; // Invalid mapping, allow original request } diff --git a/entry/src/main/ets/common/utils/RcpRequestForwarder.ets b/entry/src/main/ets/common/utils/RcpRequestForwarder.ets index 593c7b07926685bc96eb8500be61c7be0badcb09..3ce454fac3de9fc775f74fdc719fe99fe60d0c42 100644 --- a/entry/src/main/ets/common/utils/RcpRequestForwarder.ets +++ b/entry/src/main/ets/common/utils/RcpRequestForwarder.ets @@ -113,8 +113,10 @@ export class RcpRequestForwarder { this.session?.get(targetUrl).then((response: rcp.Response) => { Logger.info(TAG, `GET success: ${targetUrl}`); this.handleResponse(response, resourceHandler); + this.session?.close(); }).catch((error: BusinessError) => { Logger.error(TAG, `Failed to get, errCode: ${error.code}, errMessage: ${error.message}`); + this.session?.close(); }); } catch (error) { const err = error as BusinessError; @@ -140,16 +142,20 @@ export class RcpRequestForwarder { this.session?.post(targetUrl).then((response: rcp.Response) => { Logger.info(TAG, `${method} success: ${targetUrl}`); this.handleResponse(response, resourceHandler); + this.session?.close(); }).catch((error: BusinessError) => { Logger.error(TAG, `${method} failed, errCode: ${error.code}, errMessage: ${error.message}`); + this.session?.close(); }); break; case 'PUT': this.session?.put(targetUrl).then((response: rcp.Response) => { Logger.info(TAG, `${method} success: ${targetUrl}`); this.handleResponse(response, resourceHandler); + this.session?.close(); }).catch((error: BusinessError) => { Logger.error(TAG, `${method} failed, errCode: ${error.code}, errMessage: ${error.message}`); + this.session?.close(); }); break; case 'PATCH': @@ -157,19 +163,24 @@ export class RcpRequestForwarder { this.session?.fetch(request).then((response: rcp.Response) => { Logger.info(TAG, `${method} success: ${targetUrl}`); this.handleResponse(response, resourceHandler); + this.session?.close(); }).catch((error: BusinessError) => { Logger.error(TAG, `${method} failed, errCode: ${error.code}, errMessage: ${error.message}`); + this.session?.close(); }); break; case 'DELETE': this.session?.delete(targetUrl).then((response: rcp.Response) => { Logger.info(TAG, `${method} success: ${targetUrl}`); this.handleResponse(response, resourceHandler); + this.session?.close(); }).catch((error: BusinessError) => { Logger.error(TAG, `${method} failed, errCode: ${error.code}, errMessage: ${error.message}`); + this.session?.close(); }); break; default: + this.session?.close(); return; } } catch (error) { diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index 8115b8eac41f4df841fbd689964fb5dff98780db..e94a2f7b716d73ea7f6974bcc3ca7b87b71b5df2 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "WebInterceptor" }, { "name": "home_page_title", diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json index 6e93cec620b5a1791dc5c75a91867d40192e241b..e1ec63648357a039aa500353489a88a35c113cb0 100644 --- a/entry/src/main/resources/en_US/element/string.json +++ b/entry/src/main/resources/en_US/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "WebInterceptor" }, { "name": "home_page_title", diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index 8950ba470793bd3ffac5c6ac82a2948b468d6366..668f02baabfbb0b9b0d60b7e85aea4f400eb5d1e 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "WebInterceptor" }, { "name": "home_page_title",