本文整理汇总了Java中io.vertx.ext.web.client.WebClientOptions类的典型用法代码示例。如果您正苦于以下问题:Java WebClientOptions类的具体用法?Java WebClientOptions怎么用?Java WebClientOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebClientOptions类属于io.vertx.ext.web.client包,在下文中一共展示了WebClientOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hello7
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Path("7")
@GET
public CompletionStage<String> hello7(@Context Vertx vertx){
io.vertx.rxjava.core.Vertx rxVertx = io.vertx.rxjava.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.rxjava.core.buffer.Buffer>> responseHandler = client.get(443,
"www.google.com",
"/robots.txt").rxSend();
CompletableFuture<String> ret = new CompletableFuture<>();
responseHandler.subscribe(body -> {
System.err.println("Got body");
ret.complete(body.body().toString());
});
System.err.println("Created client");
return ret;
}
示例2: prepare
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Before
public void prepare(TestContext context) {
vertx = Vertx.vertx();
JsonObject dbConf = new JsonObject()
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_URL, "jdbc:hsqldb:mem:testdb;shutdown=true")
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_MAX_POOL_SIZE, 4);
vertx.deployVerticle(new WikiDatabaseVerticle(),
new DeploymentOptions().setConfig(dbConf), context.asyncAssertSuccess());
vertx.deployVerticle(new HttpServerVerticle(), context.asyncAssertSuccess());
webClient = WebClient.create(vertx, new WebClientOptions()
.setDefaultHost("localhost")
.setDefaultPort(8080)
.setSsl(true)
.setTrustOptions(new JksOptions().setPath("server-keystore.jks").setPassword("secret")));
}
示例3: prepare
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Before
public void prepare(TestContext context) {
vertx = Vertx.vertx();
JsonObject dbConf = new JsonObject()
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_URL, "jdbc:hsqldb:mem:testdb;shutdown=true")
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_MAX_POOL_SIZE, 4);
vertx.deployVerticle(new WikiDatabaseVerticle(),
new DeploymentOptions().setConfig(dbConf), context.asyncAssertSuccess());
vertx.deployVerticle(new HttpServerVerticle(), context.asyncAssertSuccess());
// tag::test-https[]
webClient = WebClient.create(vertx, new WebClientOptions()
.setDefaultHost("localhost")
.setDefaultPort(8080)
.setSsl(true) // <1>
.setTrustOptions(new JksOptions().setPath("server-keystore.jks").setPassword("secret"))); // <2>
// end::test-https[]
}
示例4: prepare
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Before
public void prepare(TestContext context) {
vertx = Vertx.vertx();
JsonObject dbConf = new JsonObject()
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_URL, "jdbc:hsqldb:mem:testdb;shutdown=true") // <1>
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_MAX_POOL_SIZE, 4);
vertx.deployVerticle(new WikiDatabaseVerticle(),
new DeploymentOptions().setConfig(dbConf), context.asyncAssertSuccess());
vertx.deployVerticle(new HttpServerVerticle(), context.asyncAssertSuccess());
webClient = WebClient.create(vertx, new WebClientOptions()
.setDefaultHost("localhost")
.setDefaultPort(8080));
}
示例5: initWebClient
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
private WebClient initWebClient() {
if (this.client == null) {
final WebClientOptions wco = new WebClientOptions();
final String proxyHost = this.getConsumerConfig().getProxy();
final int proxyPort = this.getConsumerConfig().getProxyPort();
if ((proxyHost != null) && (proxyPort > 0)) {
final ProxyOptions po = new ProxyOptions();
wco.setProxyOptions(po);
po.setHost(proxyHost).setPort(proxyPort);
}
// TODO: more options
wco.setUserAgent("SFDC VertX REST Provider");
wco.setTryUseCompression(true);
this.client = WebClient.create(this.vertx, wco);
}
return this.client;
}
示例6: login
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Override
protected void login(final Future<AuthInfo> futureAuthinfo) {
final WebClientOptions wco = new WebClientOptions();
final String proxyHost = this.getAuthConfig().getProxy();
final int proxyPort = this.getAuthConfig().getProxyPort();
if ((proxyHost != null) && (proxyPort > 0)) {
final ProxyOptions po = new ProxyOptions();
wco.setProxyOptions(po);
po.setHost(proxyHost).setPort(proxyPort);
}
wco.setUserAgent("SDFC VertX Authenticator");
wco.setTryUseCompression(true);
final WebClient authClient = WebClient.create(this.vertx, wco);
final Buffer body = this.getAuthBody(this.getAuthConfig().getSfdcUser(),
this.getAuthConfig().getSfdcPassword());
if (!this.shuttingDown && !this.shutdownCompleted) {
authClient.post(Constants.TLS_PORT, this.getAuthConfig().getServerURL(), Constants.AUTH_SOAP_LOGIN)
.putHeader("Content-Type", "text/xml").ssl(true).putHeader("SOAPAction", "Login")
.putHeader("PrettyPrint", "Yes").sendBuffer(body, postReturn -> {
this.resultOfAuthentication(postReturn, futureAuthinfo);
});
} else {
this.shutdownCompleted = true;
futureAuthinfo.fail("Auth disruped by stop command");
}
}
示例7: testAPIListening
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Test
public void testAPIListening(final TestContext context) {
final Async async = context.async();
final WebClientOptions wco = new WebClientOptions();
wco.setUserAgent("SDFC VertX Unit Tester");
wco.setTryUseCompression(true);
final WebClient client = WebClient.create(this.vertx, wco);
client.get(8044, "localhost", "/api").send(result -> {
if (result.succeeded()) {
context.assertEquals(200, result.result().statusCode());
} else {
context.fail(result.cause());
}
async.complete();
});
}
示例8: start
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Override
public void start() throws Exception {
tradingPair = config().getString("tradingPair");
handleFillsMessage = MessageDefinitions.HANDLE_FILLS+":"+tradingPair;
initOrderBookMessage = MessageDefinitions.INIT_ORDERBOOK+":"+tradingPair;
updateOrderBookMessage = MessageDefinitions.UPDATE_ORDERBOOK+":"+tradingPair;
setTicksMessage = MessageDefinitions.SET_LASTTICKS+":"+tradingPair;
tickIntervalStrings = new HashMap<Integer, String>();
tickIntervalStrings.put(1, "oneMin");
tickIntervalStrings.put(5, "fiveMin");
tickIntervalStrings.put(30, "thirtyMin");
tickIntervalStrings.put(60, "hour");
tickIntervalStrings.put(24*60, "day");
String userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36";
WebClientOptions options = new WebClientOptions().setUserAgent(userAgent);
headers.add("User-Agent", userAgent);
options.setKeepAlive(false);
restclient = WebClient.create(vertx, options);
getConnectionToken();
}
示例9: prepare
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Before
public void prepare(TestContext context) throws IOException {
Async async = context.async();
JsonObject config = new JsonObject().put("db_url", "jdbc:hsqldb:mem:testdb;shutdown=true")
.put("db_max_pool_size", 4)
.put("security_definitions", "classpath:wiki-users.properties")
.put("scan", new JsonArray().add(AppResource.class.getPackage().getName()))
.put("keystore", new JsonObject()
.put("path", "keystore.jceks")
.put("type", "jceks")
.put("password", "secret"));
server = new WikiServer();
server.start(config)
.subscribe(v -> {
webClient = WebClient.create(server.getVertx(),
new WebClientOptions().setDefaultHost("localhost").setDefaultPort(9000));
async.complete();
}, x -> {
x.printStackTrace();
context.fail(x);
async.complete();
});
}
示例10: hello6
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Path("6")
@GET
public void hello6(@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");
WebClientOptions options = new WebClientOptions();
options.setSsl(true);
options.setTrustAll(true);
options.setVerifyHost(false);
WebClient client = WebClient.create(rxVertx, options);
Single<HttpResponse<io.vertx.rxjava.core.buffer.Buffer>> responseHandler = client.get(443,
"www.google.com",
"/robots.txt").rxSend();
responseHandler.subscribe(body -> {
System.err.println("Got body");
asyncResponse.resume(Response.ok(body.body().toString()).build());
});
System.err.println("Created client");
}
示例11: hello7Error
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Path("7error")
@GET
public CompletionStage<String> hello7Error(@Context Vertx vertx){
io.vertx.rxjava.core.Vertx rxVertx = io.vertx.rxjava.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.rxjava.core.buffer.Buffer>> responseHandler = client.get(443,
"www.google.com",
"/robots.txt").rxSend();
CompletableFuture<String> ret = new CompletableFuture<>();
responseHandler.subscribe(body -> {
System.err.println("Got body");
ret.completeExceptionally(new MyException());
});
System.err.println("Created client");
return ret;
}
示例12: hello8
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Path("8")
@GET
public Single<String> hello8(@Context io.vertx.rxjava.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.rxjava.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();
});
}
示例13: hello8User
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Path("8user")
@Produces("text/json")
@GET
public Single<DataClass> hello8User(@Context io.vertx.rxjava.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.rxjava.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());
});
}
示例14: hello8Error
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Path("8error")
@GET
public Single<String> hello8Error(@Context io.vertx.rxjava.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.rxjava.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");
throw new MyException();
});
}
示例15: helloAsync
import io.vertx.ext.web.client.WebClientOptions; //导入依赖的package包/类
@Path("coroutines/1")
@GET
public Single<Response> helloAsync(@Context io.vertx.rxjava.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.rxjava.core.buffer.Buffer>> responseHandler = client.get(443,
"www.google.com",
"/robots.txt").rxSend();
System.err.println("Got response");
HttpResponse<io.vertx.rxjava.core.buffer.Buffer> httpResponse = Fibers.await(responseHandler);
System.err.println("Got body");
return Response.ok(httpResponse.body().toString()).build();
});
}