0

我正在尝试使用管道将大块数据传递给响应,这就是我不确定如何实现的地方。如您所见,我现在正在使用 BodyCodec.pipe (writeStream),我要做的就是在响应部分捕获该数据。

 WebClientOptions options = new WebClientOptions()
  .setSsl(webClient.isSsl());

options.setKeepAlive(true);
WebClient client = WebClient.create(MainVerticle.vertx, options);


return client
  .get(webClient.getPort(),
    webClient.getHost(),
    webClient.getUri())
  .putHeader("content-type", "application/octet-stream")
  .as(BodyCodec.pipe(writeStream)).send().onSuccess(z -> {
    System.out.println(z.bodyAsBuffer());
  });

块引用

enter code here RESPONSE -->   WriteStream<Buffer> writeStream = ReactiveWriteStream.writeStream(MainVerticle.vertx);
ServiciosWebClient serviciosWebClient = new ServiciosWebClient();

serviciosWebClient.webClientServicios182(webCliente, writeStream)
  .onSuccess(arg1 -> {

    //  Pipe<Buffer> pipe = readStream.pipeTo();

    readStream.pipeTo(writeStream).onSuccess(arg2 -> {
      System.out.println(arg2);
    });


    routingContext.
      response()
      .setStatusCode(200)
      .setChunked(true)
      .putHeader("content-type", "application/octet-stream")
      .end();

  });

 
4

0 回答 0