本文整理了Java中io.vertx.ext.web.client.HttpRequest.virtualHost()
方法的一些代码示例,展示了HttpRequest.virtualHost()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.virtualHost()
方法的具体详情如下:
包路径:io.vertx.ext.web.client.HttpRequest
类名称:HttpRequest
方法名:virtualHost
暂无
代码示例来源:origin: io.vertx/vertx-rx-java
/**
* Configure the request to use a virtual host <code>value</code>.
* <p/>
* Usually the header <i>host</i> (<i>:authority</i> pseudo header for HTTP/2) is set from the request host value
* since this host value resolves to the server IP address.
* <p/>
* Sometimes you need to set a host header for an address that does not resolve to the server IP address.
* The virtual host value overrides the value of the actual <i>host</i> header (<i>:authority</i> pseudo header
* for HTTP/2).
* <p/>
* The virtual host is also be used for SNI.
* @param value
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.ext.web.client.HttpRequest<T> virtualHost(String value) {
delegate.virtualHost(value);
return this;
}
代码示例来源:origin: vert-x3/vertx-rx
/**
* Configure the request to use a virtual host <code>value</code>.
* <p/>
* Usually the header <i>host</i> (<i>:authority</i> pseudo header for HTTP/2) is set from the request host value
* since this host value resolves to the server IP address.
* <p/>
* Sometimes you need to set a host header for an address that does not resolve to the server IP address.
* The virtual host value overrides the value of the actual <i>host</i> header (<i>:authority</i> pseudo header
* for HTTP/2).
* <p/>
* The virtual host is also be used for SNI.
* @param value
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.ext.web.client.HttpRequest<T> virtualHost(String value) {
delegate.virtualHost(value);
return this;
}
代码示例来源:origin: io.vertx/vertx-web-client
@Test
public void testVirtualHost() throws Exception {
server.requestHandler(req -> {
assertEquals("another-host:8080", req.host());
req.response().end();
});
startServer();
HttpRequest<Buffer> req = client.get("/test").virtualHost("another-host");
req.send(onSuccess(resp -> testComplete()));
await();
}
代码示例来源:origin: io.vertx/vertx-web-client
@Test
public void testVirtualHostSNI() throws Exception {
WebClientOptions clientOptions = new WebClientOptions()
.setTrustAll(true)
.setDefaultHost(DEFAULT_HTTPS_HOST)
.setDefaultPort(DEFAULT_HTTPS_PORT);
HttpServerOptions serverOptions = new HttpServerOptions()
.setSsl(true)
.setSni(true)
.setKeyStoreOptions(Cert.SNI_JKS.get())
.setPort(DEFAULT_HTTPS_PORT)
.setHost(DEFAULT_HTTPS_HOST);
testTLS(clientOptions, serverOptions, req -> req.get("/").virtualHost("host2.com").ssl(true), req -> {
assertEquals("host2.com", req.connection().indicatedServerName());
System.out.println(req.host());
});
}
内容来源于网络,如有侵权,请联系作者删除!