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


Java HttpClientOptions.setDefaultHost方法代码示例

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


在下文中一共展示了HttpClientOptions.setDefaultHost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test404Response

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Test
public void test404Response() throws Exception {
	HttpClientOptions options = new HttpClientOptions();
	options.setDefaultHost("localhost");
	options.setDefaultPort(port());

	HttpClient client = Mesh.vertx().createHttpClient(options);
	CompletableFuture<String> future = new CompletableFuture<>();
	HttpClientRequest request = client.request(HttpMethod.POST, "/api/v1/test", rh -> {
		rh.bodyHandler(bh -> {
			future.complete(bh.toString());
		});
	});
	request.end();

	String response = future.get(1, TimeUnit.SECONDS);
	assertTrue("The response string should not contain any html specific characters but it was {" + response + "} ",
			response.indexOf("<") != 0);
}
 
开发者ID:gentics,项目名称:mesh,代码行数:20,代码来源:MeshRestAPITest.java

示例2: basicTestAndThenWithErrorUnhandled

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Test
// @Ignore
public void basicTestAndThenWithErrorUnhandled() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/basicTestAndThenWithErrorUnhandled",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              Assert.assertEquals(resp.statusCode(), 500);
              Assert.assertEquals(resp.statusMessage(), "test error");
              testComplete();
            }
          });
  request.end();
  await();
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:22,代码来源:RESTServiceBlockingChainObjectTest.java

示例3: endpointFive

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Test
public void endpointFive() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointFive?val=123&tmp=456",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    Payload<String> pp = new Gson().fromJson(body.toString(), Payload.class);
                    assertEquals(pp.getValue(), new Payload<>("123" + "456").getValue());
                  });
              testComplete();
            }
          });
  request.end();
  await();
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:25,代码来源:RESTServiceSelfhostedTestStaticInitializer.java

示例4: exceptionInMethodBody

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Test
public void exceptionInMethodBody() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/exceptionInMethodBody?val=123&tmp=456",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    String val = body.getString(0, body.length());
                    System.out.println("--------exceptionInMethodBody: " + val);
                    // assertEquals(key, "val");
                    testComplete();
                  });
            }
          });
  request.end();

  await();
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:26,代码来源:RESTServiceExceptionTest.java

示例5: basicTestAndThen

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Test
// @Ignore
public void basicTestAndThen() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/basicTestAndThen",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    Assert.assertEquals(body.toString(), "2 final");
                    testComplete();
                  });
            }
          });
  request.end();
  await();
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:25,代码来源:RESTServiceChainStringTest.java

示例6: endpointOne

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Test
// @Ignore
public void endpointOne() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointOne",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    Assert.assertEquals(body.toString(), "1test final");
                    testComplete();
                  });
            }
          });
  request.end();
  await();
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:25,代码来源:RESTServiceBlockingChainObjectTest.java

示例7: exceptionInStringResponseWithErrorHandler

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Test
public void exceptionInStringResponseWithErrorHandler() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/exceptionInStringResponseWithErrorHandler?val=123&tmp=456",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    String val = body.getString(0, body.length());
                    System.out.println("--------exceptionInStringResponse: " + val);
                    // assertEquals(key, "val");
                    testComplete();
                  });
            }
          });
  request.end();

  await(5000, TimeUnit.MILLISECONDS);
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:26,代码来源:RESTServiceExceptionTest.java

示例8: endpointThree

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Test
public void endpointThree() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointThree?val=123&tmp=456",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    assertEquals(body.toString(), "123456");
                  });
              testComplete();
            }
          });
  request.end();
  await();
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:24,代码来源:RESTServiceSelfhostedTestStaticInitializer.java

示例9: endpointOne

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Test
public void endpointOne() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointOne",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    Assert.assertEquals(body.toString(), "test");
                    testComplete();
                  });
            }
          });
  request.end();
  await();
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:24,代码来源:RESTServiceSelfhostedTest.java

示例10: catchedAsyncObjectErrorDelay

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Test
public void catchedAsyncObjectErrorDelay() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/catchedAsyncObjectErrorDelay?val=123&tmp=456",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    String val = body.getString(0, body.length());
                    System.out.println("--------catchedAsyncByteErrorDelay: " + val);
                    // assertEquals(key, "val");
                    testComplete();
                  });
            }
          });
  request.end();

  await(10000, TimeUnit.MILLISECONDS);
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:26,代码来源:RESTServiceExceptionTest.java

示例11: simpleOnFailureResponseBlocking

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
@Test
public void simpleOnFailureResponseBlocking() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/simpleOnFailureResponseBlocking",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    String val = body.getString(0, body.length());
                    System.out.println("--------catchedAsyncByteErrorDelay: " + val);
                    assertEquals("on failure", val);
                    testComplete();
                  });
            }
          });
  request.end();

  await(10000, TimeUnit.MILLISECONDS);
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:26,代码来源:RESTServiceOnFailureStringResponseTest.java

示例12: SpringConfigServerStore

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
SpringConfigServerStore(Vertx vertx, JsonObject configuration) {
  String url = configuration.getString("url");
  this.timeout = configuration.getLong("timeout", 3000L);
  Objects.requireNonNull(url);

  HttpClientOptions options = new HttpClientOptions();
  try {
    URL u = new URL(url);
    options.setDefaultHost(u.getHost());
    if (u.getPort() == -1) {
      options.setDefaultPort(u.getDefaultPort());
    } else {
      options.setDefaultPort(u.getPort());
    }

    if (u.getPath() != null) {
      path = u.getPath();
    } else {
      path = "/";
    }

  } catch (MalformedURLException e) {
    throw new IllegalArgumentException("Invalid url for the spring server: " + url);
  }


  if (configuration.getString("user") != null && configuration.getString("password") != null) {
    authHeaderValue = "Basic " + Base64.getEncoder().encodeToString((configuration.getString("user")
        + ":" + configuration.getString("password")).getBytes());
  } else {
    authHeaderValue = null;
  }

  client = vertx.createHttpClient(options);

}
 
开发者ID:cescoffier,项目名称:vertx-configuration-service,代码行数:37,代码来源:SpringConfigServerStore.java

示例13: S3Store

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
/**
 * Constructs a new store
 * @param vertx the Vert.x instance
 */
public S3Store(Vertx vertx) {
  super(vertx);
  this.vertx = vertx;

  JsonObject config = vertx.getOrCreateContext().config();

  accessKey = config.getString(ConfigConstants.STORAGE_S3_ACCESS_KEY);
  Preconditions.checkNotNull(accessKey, "Missing configuration item \"" +
      ConfigConstants.STORAGE_S3_ACCESS_KEY + "\"");

  secretKey = config.getString(ConfigConstants.STORAGE_S3_SECRET_KEY);
  Preconditions.checkNotNull(secretKey, "Missing configuration item \"" +
      ConfigConstants.STORAGE_S3_SECRET_KEY + "\"");

  host = config.getString(ConfigConstants.STORAGE_S3_HOST);
  Preconditions.checkNotNull(host, "Missing configuration item \"" +
      ConfigConstants.STORAGE_S3_HOST + "\"");

  port = config.getInteger(ConfigConstants.STORAGE_S3_PORT, 80);

  bucket = config.getString(ConfigConstants.STORAGE_S3_BUCKET);
  Preconditions.checkNotNull(bucket, "Missing configuration item \"" +
      ConfigConstants.STORAGE_S3_BUCKET + "\"");

  pathStyleAccess = config.getBoolean(ConfigConstants.STORAGE_S3_PATH_STYLE_ACCESS, true);
  forceSignatureV2 = config.getBoolean(ConfigConstants.STORAGE_S3_FORCE_SIGNATURE_V2, false);
  requestExpirySeconds = config.getInteger(ConfigConstants.STORAGE_S3_REQUEST_EXPIRY_SECONDS, 600);

  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultHost(host);
  options.setDefaultPort(port);
  client = vertx.createHttpClient(options);
}
 
开发者ID:georocket,项目名称:georocket,代码行数:38,代码来源:S3Store.java

示例14: SpringConfigServerStore

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
SpringConfigServerStore(Vertx vertx, JsonObject configuration) {
  String url = configuration.getString("url");
  this.timeout = configuration.getLong("timeout", 3000L);
  Objects.requireNonNull(url);

  HttpClientOptions options = new HttpClientOptions(
    configuration.getJsonObject("httpClientConfiguration", new JsonObject()));
  try {
    URL u = new URL(url);
    options.setDefaultHost(u.getHost());
    if (u.getPort() == -1) {
      options.setDefaultPort(u.getDefaultPort());
    } else {
      options.setDefaultPort(u.getPort());
    }

    if (u.getPath() != null) {
      path = u.getPath();
    } else {
      path = "/";
    }

  } catch (MalformedURLException e) {
    throw new IllegalArgumentException("Invalid url for the spring server: " + url);
  }


  if (configuration.getString("user") != null && configuration.getString("password") != null) {
    authHeaderValue = "Basic " + Base64.getEncoder().encodeToString((configuration.getString("user")
        + ":" + configuration.getString("password")).getBytes());
  } else {
    authHeaderValue = null;
  }

  client = vertx.createHttpClient(options);

}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:38,代码来源:SpringConfigServerStore.java

示例15: AbstractMeshRestHttpClient

import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
public AbstractMeshRestHttpClient(String host, int port, boolean ssl, Vertx vertx) {
	HttpClientOptions options = new HttpClientOptions();
	options.setDefaultHost(host);
	options.setTryUseCompression(true);
	options.setDefaultPort(port);
	options.setSsl(ssl);
	this.clientOptions = options;
	this.vertx = vertx;
}
 
开发者ID:gentics,项目名称:mesh,代码行数:10,代码来源:AbstractMeshRestHttpClient.java


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