本文整理汇总了Java中io.vertx.core.http.HttpClientOptions.setTrustAll方法的典型用法代码示例。如果您正苦于以下问题:Java HttpClientOptions.setTrustAll方法的具体用法?Java HttpClientOptions.setTrustAll怎么用?Java HttpClientOptions.setTrustAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.http.HttpClientOptions
的用法示例。
在下文中一共展示了HttpClientOptions.setTrustAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hello3
import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Path("3")
@GET
public void hello3(@Suspended final AsyncResponse asyncResponse,
// Inject the Vertx instance
@Context Vertx vertx){
System.err.println("Creating client");
HttpClientOptions options = new HttpClientOptions();
options.setSsl(true);
options.setTrustAll(true);
options.setVerifyHost(false);
HttpClient client = vertx.createHttpClient(options);
client.getNow(443,
"www.google.com",
"/robots.txt",
resp -> {
System.err.println("Got response");
resp.bodyHandler(body -> {
System.err.println("Got body");
asyncResponse.resume(Response.ok(body.toString()).build());
});
});
System.err.println("Created client");
}
示例2: hello4
import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Path("4")
@GET
public void hello4(@Suspended final AsyncResponse asyncResponse,
// Inject the Vertx instance
@Context Vertx vertx){
System.err.println("Creating client");
HttpClientOptions options = new HttpClientOptions();
options.setSsl(true);
options.setTrustAll(true);
options.setVerifyHost(false);
HttpClient client = vertx.createHttpClient(options);
ObservableHandler<HttpClientResponse> responseHandler = RxHelper.observableHandler();
client.getNow(443,
"www.google.com",
"/robots.txt",
responseHandler.toHandler());
ObservableHandler<Buffer> bodyHandler = RxHelper.observableHandler();
responseHandler.subscribe(resp -> {
System.err.println("Got response");
resp.bodyHandler(bodyHandler.toHandler());
});
bodyHandler.subscribe(body -> {
System.err.println("Got body");
asyncResponse.resume(Response.ok(body.toString()).build());
});
System.err.println("Created client");
}
示例3: hello5
import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Path("5")
@GET
public void hello5(@Suspended final AsyncResponse asyncResponse,
// Inject the Vertx instance
@Context Vertx vertx){
io.vertx.rxjava.core.Vertx rxVertx = io.vertx.rxjava.core.Vertx.newInstance(vertx);
System.err.println("Creating client");
HttpClientOptions options = new HttpClientOptions();
options.setSsl(true);
options.setTrustAll(true);
options.setVerifyHost(false);
io.vertx.rxjava.core.http.HttpClient client = rxVertx.createHttpClient(options);
// DOES NOT WORK: https://github.com/vert-x3/vertx-rx/issues/13
Observable<io.vertx.rxjava.core.http.HttpClientResponse> responseHandler = client.get(443,
"www.google.com",
"/robots.txt").toObservable();
responseHandler.map(resp -> {
System.err.println("Got response");
return resp.toObservable();
})
.subscribe(body -> {
System.err.println("Got body");
asyncResponse.resume(Response.ok(body.toString()).build());
});
System.err.println("Created client");
}