From accb47febdff1924f6093d044c557645285e0b88 Mon Sep 17 00:00:00 2001 From: jinzhao Date: Wed, 30 Oct 2024 10:52:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96caPath=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jinzhao --- library/src/main/ets/ImageKnifeLoader.ets | 62 ++++++++--------------- 1 file changed, 20 insertions(+), 42 deletions(-) diff --git a/library/src/main/ets/ImageKnifeLoader.ets b/library/src/main/ets/ImageKnifeLoader.ets index fbe0fed..ca0f776 100644 --- a/library/src/main/ets/ImageKnifeLoader.ets +++ b/library/src/main/ets/ImageKnifeLoader.ets @@ -290,48 +290,26 @@ export class ImageKnifeLoader { }) } - if(request.caPath === undefined) { //采用默认证书 - let promise = httpRequest.requestInStream(request.src, { - header: headerObj, - method: http.RequestMethod.GET, - expectDataType: http.HttpDataType.ARRAY_BUFFER, - connectTimeout: 60000, - readTimeout: 0, - // usingProtocol:http.HttpProtocol.HTTP1_1 - // header: new Header('application/json') - }); - await promise.then((data: number) => { - if (data == 200 || data == 206 || data == 204) { - resBuf = combineArrayBuffers(arrayBuffers) - } else { - throw new Error("HttpDownloadClient has error, http code =" + JSON.stringify(data)) - } - }).catch((err: Error) => { - throw new Error("HttpDownloadClient download ERROR : err = " + JSON.stringify(err)) - }); - LogUtil.log("HttpDownloadClient.end:" + request.src) - } else { //采用自定义证书 - let promise = httpRequest.requestInStream(request.src, { - header: headerObj, - method: http.RequestMethod.GET, - expectDataType: http.HttpDataType.ARRAY_BUFFER, - connectTimeout: 60000, - readTimeout: 0, - // usingProtocol:http.HttpProtocol.HTTP1_1 - // header: new Header('application/json') - caPath: request.caPath, - }); - await promise.then((data: number) => { - if (data == 200 || data == 206 || data == 204) { - resBuf = combineArrayBuffers(arrayBuffers) - } else { - throw new Error("HttpDownloadClient has error, http code =" + JSON.stringify(data)) - } - }).catch((err: Error) => { - throw new Error("HttpDownloadClient download ERROR : err = " + JSON.stringify(err)) - }); - LogUtil.log("HttpDownloadClient.end:" + request.src) - } + let promise = httpRequest.requestInStream(request.src, { + header: headerObj, + method: http.RequestMethod.GET, + expectDataType: http.HttpDataType.ARRAY_BUFFER, + connectTimeout: 60000, + readTimeout: 0, + // usingProtocol:http.HttpProtocol.HTTP1_1 + // header: new Header('application/json') + caPath: request.caPath === undefined ? undefined : request.caPath, + }); + await promise.then((data: number) => { + if (data == 200 || data == 206 || data == 204) { + resBuf = combineArrayBuffers(arrayBuffers) + } else { + throw new Error("HttpDownloadClient has error, http code =" + JSON.stringify(data)) + } + }).catch((err: Error) => { + throw new Error("HttpDownloadClient download ERROR : err = " + JSON.stringify(err)) + }); + LogUtil.log("HttpDownloadClient.end:" + request.src) // 保存文件缓存 if (resBuf !== undefined && request.writeCacheStrategy !== CacheStrategy.Memory) {