当前位置: 首页>>代码示例>>Java>>正文


Java WebClientOptions类代码示例

本文整理汇总了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;
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:24,代码来源:MyResource.java

示例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")));
}
 
开发者ID:vert-x3,项目名称:vertx-guide-for-java-devs,代码行数:19,代码来源:ApiTest.java

示例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[]
}
 
开发者ID:vert-x3,项目名称:vertx-guide-for-java-devs,代码行数:21,代码来源:ApiTest.java

示例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));
}
 
开发者ID:vert-x3,项目名称:vertx-guide-for-java-devs,代码行数:18,代码来源:ApiTest.java

示例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;
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:18,代码来源:RestConsumer.java

示例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");
	}
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:27,代码来源:SoapApi.java

示例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();
	});
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:18,代码来源:ApplicationStarterTest.java

示例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();



 }
 
开发者ID:AlxGDev,项目名称:BittrexGatherer,代码行数:27,代码来源:BittrexRemoteVerticle.java

示例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();
	});
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:26,代码来源:ApiTest.java

示例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");
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:24,代码来源:MyResource.java

示例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;
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:24,代码来源:MyResource.java

示例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();
	});
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:20,代码来源:MyResource.java

示例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());
	});
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:21,代码来源:MyResource.java

示例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();
	});
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:20,代码来源:MyResource.java

示例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();
	});
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:23,代码来源:MyResource.java


注:本文中的io.vertx.ext.web.client.WebClientOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。