本文整理了Java中reactor.netty.http.client.HttpClient.tcpConfiguration()
方法的一些代码示例,展示了HttpClient.tcpConfiguration()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.tcpConfiguration()
方法的具体详情如下:
包路径:reactor.netty.http.client.HttpClient
类名称:HttpClient
方法名:tcpConfiguration
[英]Get a TcpClient from the parent HttpClient chain to use with TcpClient#connect()} or separately
[中]从父HttpClient链获取TcpClient以与TcpClient#connect()}一起使用或单独使用
代码示例来源:origin: spring-projects/spring-framework
private static HttpClient initHttpClient(ReactorResourceFactory resourceFactory) {
ConnectionProvider provider = resourceFactory.getConnectionProvider();
LoopResources resources = resourceFactory.getLoopResources();
Assert.notNull(provider, "No ConnectionProvider: is ReactorResourceFactory not initialized yet?");
Assert.notNull(resources, "No LoopResources: is ReactorResourceFactory not initialized yet?");
return HttpClient.create(provider).tcpConfiguration(tcpClient -> tcpClient.runOn(resources));
}
代码示例来源:origin: org.springframework/spring-web
private static HttpClient initHttpClient(ReactorResourceFactory resourceFactory) {
ConnectionProvider provider = resourceFactory.getConnectionProvider();
LoopResources resources = resourceFactory.getLoopResources();
Assert.notNull(provider, "No ConnectionProvider: is ReactorResourceFactory not initialized yet?");
Assert.notNull(resources, "No LoopResources: is ReactorResourceFactory not initialized yet?");
return HttpClient.create(provider).tcpConfiguration(tcpClient -> tcpClient.runOn(resources));
}
代码示例来源:origin: codecentric/spring-boot-admin
private static WebClient.Builder createDefaultWebClient(Duration connectTimeout, Duration readTimeout) {
HttpClient httpClient = HttpClient.create()
.compress(true)
.tcpConfiguration(tcp -> tcp.bootstrap(bootstrap -> bootstrap.option(
ChannelOption.CONNECT_TIMEOUT_MILLIS,
(int) connectTimeout.toMillis()
)).observe((connection, newState) -> {
if (ConnectionObserver.State.CONNECTED.equals(newState)) {
connection.addHandlerLast(new ReadTimeoutHandler(readTimeout.toMillis(),
TimeUnit.MILLISECONDS
));
}
}));
ReactorClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);
return WebClient.builder().clientConnector(connector);
}
}
代码示例来源:origin: spring-projects/spring-framework
private ReactorClientHttpConnector initConnector() {
if (bufferFactory instanceof NettyDataBufferFactory) {
ByteBufAllocator allocator = ((NettyDataBufferFactory) bufferFactory).getByteBufAllocator();
return new ReactorClientHttpConnector(this.factory, httpClient ->
httpClient.tcpConfiguration(tcpClient -> tcpClient.option(ChannelOption.ALLOCATOR, allocator)));
}
else {
return new ReactorClientHttpConnector();
}
}
代码示例来源:origin: spring-cloud/spring-cloud-gateway
.tcpConfiguration(tcpClient -> {
代码示例来源:origin: io.projectreactor.netty/reactor-netty
@Override
protected TcpClient tcpConfiguration() {
return source.tcpConfiguration();
}
}
代码示例来源:origin: reactor/reactor-netty
@Override
protected TcpClient tcpConfiguration() {
return source.tcpConfiguration();
}
}
代码示例来源:origin: reactor/reactor-netty
@Override
protected TcpClient tcpConfiguration() {
return Objects.requireNonNull(tcpClientMapper.apply(source.tcpConfiguration()),
"tcpClientMapper");
}
}
代码示例来源:origin: reactor/reactor-netty
@Override
protected TcpClient tcpConfiguration() {
return source.tcpConfiguration()
.bootstrap(this);
}
代码示例来源:origin: reactor/reactor-netty
@Override
protected TcpClient tcpConfiguration() {
return source.tcpConfiguration().bootstrap(this);
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
@Override
protected TcpClient tcpConfiguration() {
return source.tcpConfiguration()
.bootstrap(this);
}
代码示例来源:origin: reactor/reactor-netty
@Override
protected TcpClient tcpConfiguration() {
return source.tcpConfiguration()
.bootstrap(this);
}
代码示例来源:origin: reactor/reactor-netty
@Override
protected TcpClient tcpConfiguration() {
return new OnErrorTcpClient(source.tcpConfiguration(),
onRequestError,
onResponseError);
}
代码示例来源:origin: reactor/reactor-netty
/**
* The address to which this client should connect for each subscribe.
*
* @param connectAddressSupplier A supplier of the address to connect to.
*
* @return a new {@link HttpClient}
*/
public final HttpClient addressSupplier(Supplier<? extends SocketAddress> connectAddressSupplier) {
Objects.requireNonNull(connectAddressSupplier, "connectAddressSupplier");
return tcpConfiguration(tcpClient -> tcpClient.addressSupplier(connectAddressSupplier));
}
代码示例来源:origin: reactor/reactor-netty
/**
* The port to which this client should connect.
*
* @param port The port to connect to.
*
* @return a new {@link HttpClient}
*/
public final HttpClient port(int port) {
return tcpConfiguration(tcpClient -> tcpClient.port(port));
}
代码示例来源:origin: reactor/reactor-netty
@Override
protected TcpClient tcpConfiguration() {
if (sslProvider == null) {
return source.tcpConfiguration()
.secure(DEFAULT_HTTP_SSL_PROVIDER);
}
return source.tcpConfiguration().secure(
SslProvider.addHandlerConfigurator(sslProvider, DEFAULT_HOSTNAME_VERIFICATION));
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* Apply a wire logger configuration using {@link HttpClient} category
* and {@code DEBUG} logger level
*
* @return a new {@link HttpClient}
* @deprecated Use {@link HttpClient#wiretap(boolean)}
*/
@Deprecated
public final HttpClient wiretap() {
return tcpConfiguration(tcpClient -> tcpClient.bootstrap(
b -> BootstrapHandlers.updateLogSupport(b, LOGGING_HANDLER)));
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* The HTTP protocol to support. Default is {@link HttpProtocol#HTTP11}.
*
* @param supportedProtocols The various {@link HttpProtocol} this server will support
*
* @return a new {@link HttpClient}
*/
public final HttpClient protocol(HttpProtocol... supportedProtocols) {
return tcpConfiguration(tcpClient -> tcpClient.bootstrap(b -> HttpClientConfiguration.protocols(b, supportedProtocols)));
}
代码示例来源:origin: reactor/reactor-netty
/**
* Use the passed HTTP method to connect the {@link HttpClient}.
*
* @param method the HTTP method to send
*
* @return a {@link RequestSender} ready to finalize request and consume for response
*/
public RequestSender request(HttpMethod method) {
Objects.requireNonNull(method, "method");
TcpClient tcpConfiguration = tcpConfiguration().bootstrap(b -> HttpClientConfiguration.method(b, method));
return new HttpClientFinalizer(tcpConfiguration);
}
代码示例来源:origin: reactor/reactor-netty
@Test
public void simpleTest404_1() {
ConnectionProvider pool = ConnectionProvider.fixed("http", 1);
HttpClient client =
HttpClient.create(pool)
.port(80)
.tcpConfiguration(tcpClient -> tcpClient.host("google.com"))
.wiretap(true);
doSimpleTest404(client);
doSimpleTest404(client);
pool.dispose();
}
内容来源于网络,如有侵权,请联系作者删除!