io.vertx.reactivex.ext.web.client.WebClient.close()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中io.vertx.reactivex.ext.web.client.WebClient.close()方法的一些代码示例,展示了WebClient.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.close()方法的具体详情如下:
包路径:io.vertx.reactivex.ext.web.client.WebClient
类名称:WebClient
方法名:close

WebClient.close介绍

暂无

代码示例

代码示例来源:origin: com.cv4j.netdiscovery/netdiscovery-core

public void close() {

    if (webClient!=null) {
      webClient.close();
    }
  }
}

代码示例来源:origin: FroMage/redpipe

private Single<String> get(Vertx vertx, URI uri){
  WebClient client = WebClient.create(vertx);
  Single<HttpResponse<Buffer>> responseHandler = 
      client.get(uri.getPort(), uri.getHost(), uri.getPath()).rxSend();
  return responseHandler.map(response -> response.body().toString())
      .doAfterTerminate(() -> client.close());
}

代码示例来源:origin: FroMage/redpipe

@Path("7error")
@GET
public CompletionStage<String> hello7Error(@Context Vertx vertx){
  io.vertx.reactivex.core.Vertx rxVertx = io.vertx.reactivex.core.Vertx.newInstance(vertx);
  System.err.println("Creating client");
  WebClientOptions options = new WebClientOptions();
  options.setSsl(true);
  options.setTrustAll(true);
  options.setVerifyHost(false);
  WebClient client = WebClient.create(rxVertx, options);
  Single<HttpResponse<io.vertx.reactivex.core.buffer.Buffer>> responseHandler = client.get(443,
      "www.google.com", 
      "/robots.txt").rxSend();
  CompletableFuture<String> ret = new CompletableFuture<>();
  responseHandler
    .doAfterTerminate(() -> client.close())
    .subscribe(body -> {
    System.err.println("Got body");
    
    ret.completeExceptionally(new MyException());
  });
  System.err.println("Created client");
  return ret;
}

代码示例来源:origin: FroMage/redpipe

@Path("coroutines/1")
  @GET
  public Single<Response> helloAsync(@Context io.vertx.reactivex.core.Vertx rxVertx){
    return Fibers.fiber(() -> {
      System.err.println("Creating client");
      WebClientOptions options = new WebClientOptions();
      options.setSsl(true);
      options.setTrustAll(true);
      options.setVerifyHost(false);
      WebClient client = WebClient.create(rxVertx, options);
      Single<HttpResponse<io.vertx.reactivex.core.buffer.Buffer>> responseHandler = client.get(443,
          "www.google.com", 
          "/robots.txt").rxSend();

      System.err.println("Got response");

      HttpResponse<io.vertx.reactivex.core.buffer.Buffer> httpResponse = Fibers.await(responseHandler);
      System.err.println("Got body");
      client.close();
      
      return Response.ok(httpResponse.body().toString()).build();
    });
  }
}

代码示例来源:origin: FroMage/redpipe

@Path("7")
@GET
public CompletionStage<String> hello7(@Context Vertx vertx){
  io.vertx.reactivex.core.Vertx rxVertx = io.vertx.reactivex.core.Vertx.newInstance(vertx);
  System.err.println("Creating client");
  WebClientOptions options = new WebClientOptions();
  options.setSsl(true);
  options.setTrustAll(true);
  options.setVerifyHost(false);
  WebClient client = WebClient.create(rxVertx, options);
  Single<HttpResponse<io.vertx.reactivex.core.buffer.Buffer>> responseHandler = client.get(443,
      "www.google.com", 
      "/robots.txt").rxSend();
  CompletableFuture<String> ret = new CompletableFuture<>();
  responseHandler
    .doAfterTerminate(() -> client.close())
    .subscribe(body -> {
    System.err.println("Got body");
    ret.complete(body.body().toString());
  });
  
  System.err.println("Created client");
  return ret;
}

代码示例来源:origin: FroMage/redpipe

@Path("8user")
@Produces("text/json")
@GET
public Single<DataClass> hello8User(@Context io.vertx.reactivex.core.Vertx rxVertx){
  System.err.println("Creating client");
  WebClientOptions options = new WebClientOptions();
  options.setSsl(true);
  options.setTrustAll(true);
  options.setVerifyHost(false);
  WebClient client = WebClient.create(rxVertx, options);
  Single<HttpResponse<io.vertx.reactivex.core.buffer.Buffer>> responseHandler = client.get(443,
      "www.google.com", 
      "/robots.txt").rxSend();
  System.err.println("Created client");
  return responseHandler.map(body -> {
    System.err.println("Got body");
    return new DataClass(body.body().toString());
  }).doAfterTerminate(() -> client.close());
}

代码示例来源:origin: FroMage/redpipe

@Path("8")
@GET
public Single<String> hello8(@Context io.vertx.reactivex.core.Vertx rxVertx){
  System.err.println("Creating client");
  WebClientOptions options = new WebClientOptions();
  options.setSsl(true);
  options.setTrustAll(true);
  options.setVerifyHost(false);
  WebClient client = WebClient.create(rxVertx, options);
  Single<HttpResponse<io.vertx.reactivex.core.buffer.Buffer>> responseHandler = client.get(443,
      "www.google.com", 
      "/robots.txt").rxSend();
  System.err.println("Created client");
  return responseHandler.map(body -> {
    System.err.println("Got body");
    return body.body().toString();
  }).doAfterTerminate(() -> client.close());
}

代码示例来源:origin: FroMage/redpipe

@Path("8error")
@GET
public Single<String> hello8Error(@Context io.vertx.reactivex.core.Vertx rxVertx){
  System.err.println("Creating client");
  WebClientOptions options = new WebClientOptions();
  options.setSsl(true);
  options.setTrustAll(true);
  options.setVerifyHost(false);
  WebClient client = WebClient.create(rxVertx, options);
  Single<HttpResponse<io.vertx.reactivex.core.buffer.Buffer>> responseHandler = client.get(443,
      "www.google.com", 
      "/robots.txt").rxSend();
  System.err.println("Created client");
  return responseHandler
      .doAfterTerminate(() -> client.close())
      .map(body -> {
    System.err.println("Got body");
    throw new MyException();
  });
}

代码示例来源:origin: FroMage/redpipe

@Path("6")
@GET
public void hello6(@Suspended final AsyncResponse asyncResponse,
     // Inject the Vertx instance
     @Context Vertx vertx){
  io.vertx.reactivex.core.Vertx rxVertx = io.vertx.reactivex.core.Vertx.newInstance(vertx);
  System.err.println("Creating client");
  WebClientOptions options = new WebClientOptions();
  options.setSsl(true);
  options.setTrustAll(true);
  options.setVerifyHost(false);
  WebClient client = WebClient.create(rxVertx, options);
  Single<HttpResponse<io.vertx.reactivex.core.buffer.Buffer>> responseHandler = client.get(443,
      "www.google.com", 
      "/robots.txt").rxSend();
  responseHandler
    .doAfterTerminate(() -> client.close())
    .subscribe(body -> {
    System.err.println("Got body");
    asyncResponse.resume(Response.ok(body.body().toString()).build());
  });
  
  System.err.println("Created client");
}

代码示例来源:origin: FroMage/redpipe

.as(BodyCodec.jsonObject())
    .rxSendJsonObject(gistPayload));
webClient.close();

代码示例来源:origin: FroMage/redpipe

.as(BodyCodec.jsonObject())
    .rxSendJsonObject(gistPayload));
webClient.close();

相关文章