HarmonyOS 使用http接口获取图片流result为空

返回响应体

{"responseCode":200,"cookies":"","header":{"content-length":"1744","content-type":"application/json; charset=utf-8","date":"Wed, 06 Mar 2024 08:26:49 GMT","server":"nginx"},"result":{},"resultType":2,"performanceTiming":{"dnsTiming":0.159,"firstReceiveTiming":1301.064,"firstSendTiming":0.409,"redirectTiming":0,"responseBodyTiming":1302.414,"responseHeaderTiming":1302.405,"tcpTiming":0,"tlsTiming":0,"totalFinishTiming":1301.302,"totalTiming":1303.02}}
http.createHttp().request(
  `https://preapps.eshiyun.info/account/image/getCode?uuid=${this.generateRandomNumber(32)}`,
  {
    expectDataType: http.HttpDataType.ARRAY_BUFFER,
    method: http.RequestMethod.GET,
    header: {
      // 在每个请求前添加自定义头部信息
      'User-Agent': 'OS/Android:14 smyapp/standardsmy Brand/Xiaomi:2211133C Display/1080*2252 standardsmy/2.7.5.02',
      'eshimin-version': '2.7.5.02',
      'system-version': '14',
      'nonce': randomChar,
      'timeStamp': currentTime.toString(),
      'sign': sign,
      'uri': '/account/image/getCode',
      'hversion': '2.1',
      'tgt': tgt,
      'token': tgt
    }
  }
HarmonyOS
2天前
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
shlp

可以在回调方法内通过 ArrayBuffer 参数接收,再打印字节长度来判断响应内容是否为空,如

let imageData: ArrayBuffer = data.result as ArrayBuffer;
console.info("data length:" + imageData.byteLength);
分享
微博
QQ
微信
回复
2天前
相关问题
使用http模块实现数据请求
1141浏览 • 1回复 待解决
sim.getOpNameSync获取到的值
228浏览 • 0回复 待解决
info 获取是失败 一直
1898浏览 • 1回复 待解决
app.getInfo获取应用配置信息
700浏览 • 1回复 待解决
HarmonyOS http使用axios库的接口缓存
40浏览 • 1回复 待解决
HarmonyOS http请求数据报错
25浏览 • 1回复 待解决
mongodb查找附近的单车
6155浏览 • 1回复 待解决