static get() { const uri = "https://gitee.com/static/images/logo-black.svg?t=158106664"; try { const req = http.createHttp(); req.on('headersReceive', (headers: Object) => { console.info(tag + 'headersReceive: ' + JSON.stringify(headers)); }) req.on('dataReceive', (data: ArrayBuffer) => { console.info(tag + 'dataReceive: ' + JSON.stringify(data)); }) req.on('dataReceiveProgress', (data: http.DataReceiveProgressInfo) => { console.info(tag + 'dataReceiveProgress: ' + JSON.stringify(data)); }) req.requestInStream(uri) .then((data: number) => { console.info(tag + 'request success, resp: ' + JSON.stringify(data)); req.destroy(); console.info(tag + 'request destroy'); }) .catch((err: BusinessError) => { console.info(tag + 'request failed, err: ' + JSON.stringify(err)); }) } catch (err) { console.log(tag + 'httpRequest_get err : ' + JSON.stringify(err)); } }使用 req.requestInStreamhttps://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-http-V5\#requestinstream10
使用 req.requestInStream
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-http-V5\#requestinstream10