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


Java HttpClientOptions类代码示例

本文整理汇总了Java中io.vertx.core.http.HttpClientOptions的典型用法代码示例。如果您正苦于以下问题:Java HttpClientOptions类的具体用法?Java HttpClientOptions怎么用?Java HttpClientOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpClientOptions类属于io.vertx.core.http包,在下文中一共展示了HttpClientOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:24,代码来源:MyResource.java

示例2: createHttpClientOptions

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
private HttpClientOptions createHttpClientOptions() {
  HttpClientOptions httpClientOptions = new HttpClientOptions();
  httpClientOptions.setConnectTimeout(CONFIG_CENTER_CONFIG.getConnectionTimeout());
  if (serverUri.get(0).toLowerCase().startsWith("https")) {
    LOGGER.debug("service center client performs requests over TLS");
    SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY,
        ConfigCenterConfig.INSTANCE.getConcurrentCompositeConfiguration());
    SSLOption sslOption;
    if (factory == null) {
      sslOption = SSLOption.buildFromYaml(SSL_KEY,
          ConfigCenterConfig.INSTANCE.getConcurrentCompositeConfiguration());
    } else {
      sslOption = factory.createSSLOption();
    }
    SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
    VertxTLSBuilder.buildHttpClientOptions(sslOption, sslCustom, httpClientOptions);
  }
  return httpClientOptions;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:20,代码来源:ConfigCenterClient.java

示例3: testbuildClientOptionsBaseAuthPeerFalse

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
@Test
public void testbuildClientOptionsBaseAuthPeerFalse() {
  SSLOption option = SSLOption.buildFromYaml("rest.consumer");
  SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
  HttpClientOptions serverOptions = new HttpClientOptions();
  new MockUp<SSLOption>() {

    @Mock
    public boolean isAuthPeer() {
      return false;
    }
  };
  VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
  Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
  Assert.assertEquals(serverOptions.isTrustAll(), true);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:TestVertxTLSBuilder.java

示例4: testbuildClientOptionsBaseSTORE_JKS

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
@Test
public void testbuildClientOptionsBaseSTORE_JKS() {
  SSLOption option = SSLOption.buildFromYaml("rest.consumer");
  SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
  HttpClientOptions serverOptions = new HttpClientOptions();
  new MockUp<SSLOption>() {

    @Mock
    public String getKeyStoreType() {
      return "JKS";
    }
  };
  VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
  Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
  Assert.assertEquals(serverOptions.isTrustAll(), true);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:TestVertxTLSBuilder.java

示例5: testbuildClientOptionsBaseSTORE_PKCS12

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
@Test
public void testbuildClientOptionsBaseSTORE_PKCS12() {
  SSLOption option = SSLOption.buildFromYaml("rest.consumer");
  SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
  HttpClientOptions serverOptions = new HttpClientOptions();
  new MockUp<SSLOption>() {

    @Mock
    public String getTrustStoreType() {
      return "PKCS12";
    }
  };
  VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
  Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
  Assert.assertEquals(serverOptions.isTrustAll(), true);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:TestVertxTLSBuilder.java

示例6: createHttpClientOptions

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
@Override
public HttpClientOptions createHttpClientOptions() {
  HttpVersion ver = ServiceRegistryConfig.INSTANCE.getHttpVersion();
  HttpClientOptions httpClientOptions = new HttpClientOptions();
  httpClientOptions.setProtocolVersion(ver);
  httpClientOptions.setConnectTimeout(ServiceRegistryConfig.INSTANCE.getConnectionTimeout());
  httpClientOptions.setIdleTimeout(ServiceRegistryConfig.INSTANCE.getIdleWatchTimeout());
  if (ver == HttpVersion.HTTP_2) {
    LOGGER.debug("service center ws client protocol version is HTTP/2");
    httpClientOptions.setHttp2ClearTextUpgrade(false);
  }
  if (ServiceRegistryConfig.INSTANCE.isSsl()) {
    LOGGER.debug("service center ws client performs requests over TLS");
    VertxTLSBuilder.buildHttpClientOptions(SSL_KEY, httpClientOptions);
  }
  return httpClientOptions;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:18,代码来源:WebsocketClientPool.java

示例7: createHttpClientOptions

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
@Override
public HttpClientOptions createHttpClientOptions() {
  HttpVersion ver = ServiceRegistryConfig.INSTANCE.getHttpVersion();
  HttpClientOptions httpClientOptions = new HttpClientOptions();
  httpClientOptions.setProtocolVersion(ver);
  httpClientOptions.setConnectTimeout(ServiceRegistryConfig.INSTANCE.getConnectionTimeout());
  httpClientOptions.setIdleTimeout(ServiceRegistryConfig.INSTANCE.getIdleConnectionTimeout());
  if (ServiceRegistryConfig.INSTANCE.isProxyEnable()) {
    ProxyOptions proxy = new ProxyOptions();
    proxy.setHost(ServiceRegistryConfig.INSTANCE.getProxyHost());
    proxy.setPort(ServiceRegistryConfig.INSTANCE.getProxyPort());
    proxy.setUsername(ServiceRegistryConfig.INSTANCE.getProxyUsername());
    proxy.setPassword(ServiceRegistryConfig.INSTANCE.getProxyPasswd());
    httpClientOptions.setProxyOptions(proxy);
  }
  if (ver == HttpVersion.HTTP_2) {
    LOGGER.debug("service center client protocol version is HTTP/2");
    httpClientOptions.setHttp2ClearTextUpgrade(false);
  }
  if (ServiceRegistryConfig.INSTANCE.isSsl()) {
    LOGGER.debug("service center client performs requests over TLS");
    VertxTLSBuilder.buildHttpClientOptions(SSL_KEY, httpClientOptions);
  }
  return httpClientOptions;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:26,代码来源:HttpClientPool.java

示例8: testPrivateMethodCreateHttpClientOptions

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
@Test
public void testPrivateMethodCreateHttpClientOptions() {
  MicroserviceFactory microserviceFactory = new MicroserviceFactory();
  Microservice microservice = microserviceFactory.create("app", "ms");
  oClient.registerMicroservice(microservice);
  oClient.registerMicroserviceInstance(microservice.getInstance());
  new MockUp<ServiceRegistryConfig>() {
    @Mock
    public HttpVersion getHttpVersion() {
      return HttpVersion.HTTP_2;
    }

    @Mock
    public boolean isSsl() {
      return true;
    }
  };
  try {
    oClient.init();
    HttpClientOptions httpClientOptions = Deencapsulation.invoke(oClient, "createHttpClientOptions");
    Assert.assertNotNull(httpClientOptions);
    Assert.assertEquals(80, httpClientOptions.getDefaultPort());
  } catch (Exception e) {
    Assert.assertNotNull(e);
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:27,代码来源:TestServiceRegistryClientImpl.java

示例9: setupHttpClient

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
private void setupHttpClient(String connectionToken, String protocolVersion){

 if(client != null){
  client.close();
 }
 
 UriComponentsBuilder urlBuilder = UriComponentsBuilder.fromUriString("/signalr/connect");
	  urlBuilder.queryParam("transport", "webSockets");
	  urlBuilder.queryParam("clientProtocol", protocolVersion);
	  urlBuilder.queryParam("connectionToken", connectionToken);
	  urlBuilder.queryParam("connectionData", "[{\"name\":\"corehub\"}]");
	
	  String endPoint = urlBuilder.build().encode().toUriString();
 
 HttpClientOptions options = new HttpClientOptions();
 
 options.setMaxWebsocketFrameSize(1000000);
 options.setMaxWebsocketMessageSize(1000000);
 
 client = vertx.createHttpClient(options);
 connectToBittrex(endPoint);
}
 
开发者ID:AlxGDev,项目名称:BittrexGatherer,代码行数:23,代码来源:BittrexRemoteVerticle.java

示例10: httpClientOptions

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
@Bean
public HttpClientOptions httpClientOptions() {

    final HttpClientOptions options = new HttpClientOptions()
        .setPipelining(true);
    if (httpClientProxyHost != null) {
        final ProxyOptions proxyOptions = new ProxyOptions()
            .setHost(httpClientProxyHost)
            .setPort(httpClientProxyPort)
            .setType(httpClientProxyType)
            .setUsername(httpClientProxyUsername)
            .setPassword(httpClientProxyPassword);
        options.setProxyOptions(proxyOptions);
    }
    return options;
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:17,代码来源:VertxConfig.java

示例11: setup

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
@Before
public void setup(TestContext context) {
  this.vertx = Vertx.vertx();
  Router router = Router.router(vertx);
  router.get("/object").handler(this::getData);
  router.get("/array").handler(this::getArray);
  router.get("/400").handler(this::get400);
  router.get("/badobject").handler(this::getBadObject);
  router.get("/badarray").handler(this::getBadArray);

  // TODO: get random available port

  this.httpServer = vertx.createHttpServer()
      .requestHandler(router::accept)
      .listen(port, context.asyncAssertSuccess());

  this.httpClient = vertx.createHttpClient(
      new HttpClientOptions()
          .setDefaultHost("localhost")
          .setDefaultPort(port)
  );
}
 
开发者ID:dazraf,项目名称:vertx-futures,代码行数:23,代码来源:HttpTest.java

示例12: HttpSender

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
/**
 * @param vertx   vertx instance to create the socket from
 * @param context of execution to run operations that need vertx initialized
 * @param options Statful options to configure host and port
 */
public HttpSender(final Vertx vertx, final Context context, final StatfulMetricsOptions options) {
    super(options, new Sampler(options, new Random()));

    this.options = options;

    context.runOnContext(aVoid -> {
        final HttpClientOptions httpClientOptions = new HttpClientOptions()
                .setDefaultHost(options.getHost())
                .setDefaultPort(options.getPort())
                .setSsl(options.isSecure());

        this.client = vertx.createHttpClient(httpClientOptions);
        this.configureFlushInterval(vertx, this.options.getFlushInterval());
    });
}
 
开发者ID:statful,项目名称:statful-client-vertx,代码行数:21,代码来源:HttpSender.java

示例13: create

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
MethodHandler create(
    final Target<?> target,
    final MethodMetadata metadata,
    final RequestTemplate.Factory buildTemplateFromArgs,
    final HttpClientOptions options,
    final Decoder decoder,
    final ErrorDecoder errorDecoder) {
  return new AsynchronousMethodHandler(
      target,
      client,
      retryer,
      requestInterceptors,
      logger,
      logLevel,
      metadata,
      buildTemplateFromArgs,
      options,
      decoder,
      errorDecoder,
      decode404);
}
 
开发者ID:OpenFeign,项目名称:feign-vertx,代码行数:22,代码来源:AsynchronousMethodHandler.java

示例14: testCORS

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
@Test
public void testCORS(TestContext context) {
    JsonObject config = TestConfig.getApiConfig();
    config.getJsonObject("cors").put("enable", true).put("origin", "https://localhost:8888");
    deployApiVerticle(context, config);

    final Async asyncClient = context.async();

    String myOrigin = "https://localhost:8888";

    HttpClientOptions sslOpts = new HttpClientOptions().setSsl(true)
            .setPemTrustOptions(TestConfig.HTTP_API_CERTIFICATE.trustOptions());

    vertx.createHttpClient(sslOpts).get(port, "localhost", "/api/v1.0/pr/latest", res -> {
        context.assertEquals(200, res.statusCode());
        context.assertEquals(myOrigin, res.getHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
        asyncClient.complete();
    }).putHeader(HttpHeaders.ORIGIN, myOrigin).end();
}
 
开发者ID:Deutsche-Boerse-Risk,项目名称:DAVe,代码行数:20,代码来源:ApiVerticleTest.java

示例15: testSslServerAuthentication

import io.vertx.core.http.HttpClientOptions; //导入依赖的package包/类
@Test
public void testSslServerAuthentication(TestContext context) {
    JsonObject config = TestConfig.getApiConfig();
    deployApiVerticle(context, config);

    final Async asyncSslClient = context.async();

    HttpClientOptions sslOpts = new HttpClientOptions().setSsl(true)
            .setPemTrustOptions(TestConfig.HTTP_API_CERTIFICATE.trustOptions());

    vertx.createHttpClient(sslOpts).get(port, "localhost", "/api/v1.0/pr/latest", res -> {
        context.assertEquals(200, res.statusCode());
        asyncSslClient.complete();
    }).end();

    final Async asyncClient = context.async();

    vertx.createHttpClient().get(port, "localhost", "/api/v1.0/pr/latest", res ->
        context.fail("Connected to HTTPS connection with HTTP!")
    ).exceptionHandler(res ->
        asyncClient.complete()
    ).end();
}
 
开发者ID:Deutsche-Boerse-Risk,项目名称:DAVe,代码行数:24,代码来源:ApiVerticleTest.java


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