code: public void buildChunkInfoList() {
      List<ChunkInfo> chunkInfoList = new ArrayList<>();
      List<ConnectInfo> connectInfoList = new ArrayList<>();
      if (response.getTotalSize() > 0) {  //非chunked编码
        //如果文件太小，连接数过高，则调整连接数量
        if (response.getTotalSize() < downConfig.getConnections()) {
          downConfig.setConnections((int) response.getTotalSize());
        }
        //计算chunk列表
        long chunkSize = response.getTotalSize() / downConfig.getConnections();
        for (int i = 0; i < downConfig.getConnections(); i++) {
          ChunkInfo chunkInfo = new ChunkInfo();
          ConnectInfo connectInfo = new ConnectInfo();
          chunkInfo.setIndex(i);
          long start = i * chunkSize;
          if (i == downConfig.getConnections() - 1) { //最后一个连接去下载多出来的字节
            chunkSize += response.getTotalSize() % downConfig.getConnections();
          }
          long end = start + chunkSize - 1;
          chunkInfo.setTotalSize(chunkSize);
          if (taskInfo.getLastPauseTime() > 0) {
            chunkInfo.setLastPauseTime(taskInfo.getLastPauseTime());
            chunkInfo.setPauseTime(taskInfo.getLastPauseTime() - taskInfo.getStartTime());
          }
          chunkInfoList.add(chunkInfo);
  
          connectInfo.setChunkIndex(i);
          connectInfo.setStartPosition(start);
          connectInfo.setEndPosition(end);
          connectInfoList.add(connectInfo);
        }
      } else { //chunked下载
        ChunkInfo chunkInfo = new ChunkInfo();
        ConnectInfo connectInfo = new ConnectInfo();
        connectInfo.setChunkIndex(0);
        chunkInfo.setIndex(0);
        if (taskInfo.getLastPauseTime() > 0) {
          chunkInfo.setLastPauseTime(taskInfo.getLastPauseTime());
          chunkInfo.setPauseTime(taskInfo.getLastPauseTime() - taskInfo.getStartTime());
        }
        chunkInfoList.add(chunkInfo);
        connectInfoList.add(connectInfo);
      }
      taskInfo.setChunkInfoList(chunkInfoList);
      taskInfo.setConnectInfoList(connectInfoList);
    }
docs: 生成下载分段信息