本文整理了Java中reactor.netty.http.client.HttpClient.from()
方法的一些代码示例,展示了HttpClient.from()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.from()
方法的具体详情如下:
包路径:reactor.netty.http.client.HttpClient
类名称:HttpClient
方法名:from
[英]Prepare a pooled HttpClient
[中]准备一个池式HttpClient
代码示例来源:origin: spring-projects/spring-data-elasticsearch
private static WebClientProvider getWebClientProvider(ClientConfiguration clientConfiguration) {
Duration connectTimeout = clientConfiguration.getConnectTimeout();
Duration soTimeout = clientConfiguration.getSocketTimeout();
TcpClient tcpClient = TcpClient.create();
if (!connectTimeout.isNegative()) {
tcpClient = tcpClient.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, Math.toIntExact(connectTimeout.toMillis()));
}
if (!soTimeout.isNegative()) {
tcpClient = tcpClient.doOnConnected(connection -> connection //
.addHandlerLast(new ReadTimeoutHandler(soTimeout.toMillis(), TimeUnit.MILLISECONDS))
.addHandlerLast(new WriteTimeoutHandler(soTimeout.toMillis(), TimeUnit.MILLISECONDS)));
}
String scheme = "http";
HttpClient httpClient = HttpClient.from(tcpClient);
if (clientConfiguration.useSsl()) {
httpClient = httpClient.secure(sslConfig -> {
Optional<SSLContext> sslContext = clientConfiguration.getSslContext();
sslContext.ifPresent(it -> sslConfig.sslContext(new JdkSslContext(it, true, ClientAuth.NONE)));
});
scheme = "https";
}
ReactorClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);
WebClientProvider provider = WebClientProvider.create(scheme, connector);
return provider.withDefaultHeaders(clientConfiguration.getDefaultHeaders());
}
代码示例来源:origin: rsocket/rsocket-java
/**
* Creates a new instance
*
* @param client the {@link TcpClient} to use
* @return a new instance
* @throws NullPointerException if {@code client} or {@code path} is {@code null}
*/
public static WebsocketClientTransport create(TcpClient client) {
Objects.requireNonNull(client, "client must not be null");
return create(HttpClient.from(client), "/");
}
代码示例来源:origin: rsocket/rsocket-java
/**
* Creates a new instance
*
* @param uri the URI to connect to
* @return a new instance
* @throws NullPointerException if {@code uri} is {@code null}
*/
public static WebsocketClientTransport create(URI uri) {
Objects.requireNonNull(uri, "uri must not be null");
TcpClient client = createClient(uri);
return create(HttpClient.from(client), uri.getPath());
}
代码示例来源:origin: io.rsocket/rsocket-transport-netty
/**
* Creates a new instance
*
* @param client the {@link TcpClient} to use
* @return a new instance
* @throws NullPointerException if {@code client} or {@code path} is {@code null}
*/
public static WebsocketClientTransport create(TcpClient client) {
Objects.requireNonNull(client, "client must not be null");
return create(HttpClient.from(client), "/");
}
代码示例来源:origin: io.rsocket/rsocket-transport-netty
/**
* Creates a new instance
*
* @param uri the URI to connect to
* @return a new instance
* @throws NullPointerException if {@code uri} is {@code null}
*/
public static WebsocketClientTransport create(URI uri) {
Objects.requireNonNull(uri, "uri must not be null");
TcpClient client = createClient(uri);
return create(HttpClient.from(client), uri.getPath());
}
内容来源于网络,如有侵权,请联系作者删除!