收藏
回答

RequestTask.onChunkReceived只执行一次?

wx.request({
  enableChunked: true
})
public ResponseEntity<StreamingResponseBody> getChunkedData() {
    return ResponseEntity.ok().body(out -> {
        out.write("This is chunk 1".getBytes());
        out.flush();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        out.write("This is chunk 2".getBytes());
        out.flush();
    });
}

按理来说flush了2次,onChunkReceived方法应该回调2次,实际console打印函数只执行了一次,就是全部返回了

回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容