Search in sources :

Example 6 with ReactorClientHttpConnector

use of org.springframework.http.client.reactive.ReactorClientHttpConnector in project spring-boot by spring-projects.

the class AbstractReactiveWebServerFactoryTests method getWebClient.

protected WebClient.Builder getWebClient(HttpClient client, int port) {
    InetSocketAddress address = new InetSocketAddress(port);
    String baseUrl = "http://" + address.getHostString() + ":" + address.getPort();
    return WebClient.builder().clientConnector(new ReactorClientHttpConnector(client)).baseUrl(baseUrl);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ReactorClientHttpConnector(org.springframework.http.client.reactive.ReactorClientHttpConnector)

Example 7 with ReactorClientHttpConnector

use of org.springframework.http.client.reactive.ReactorClientHttpConnector in project spring-boot by spring-projects.

the class AbstractReactiveWebServerFactoryTests method buildTrustAllSslConnector.

protected ReactorClientHttpConnector buildTrustAllSslConnector() {
    Http11SslContextSpec sslContextSpec = Http11SslContextSpec.forClient().configure((builder) -> builder.sslProvider(SslProvider.JDK).trustManager(InsecureTrustManagerFactory.INSTANCE));
    HttpClient client = HttpClient.create().wiretap(true).secure((spec) -> spec.sslContext(sslContextSpec));
    return new ReactorClientHttpConnector(client);
}
Also used : HttpClient(reactor.netty.http.client.HttpClient) Http11SslContextSpec(reactor.netty.http.Http11SslContextSpec) ReactorClientHttpConnector(org.springframework.http.client.reactive.ReactorClientHttpConnector)

Example 8 with ReactorClientHttpConnector

use of org.springframework.http.client.reactive.ReactorClientHttpConnector in project JavaForFun by gumartinm.

the class ServicesConfig method webClientBuilder.

@Bean
public WebClient.Builder webClientBuilder() {
    ClientHttpConnector connector = new ReactorClientHttpConnector(options -> {
        options.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectionTimeOut).onChannelInit(channel -> {
            channel.pipeline().addLast(new ReadTimeoutHandler(readTimeOut, TimeUnit.MILLISECONDS));
            channel.pipeline().addLast(new WriteTimeoutHandler(writeTimeout, TimeUnit.MILLISECONDS));
            return true;
        });
    });
    WebClient.Builder webClientBuilder = WebClient.builder();
    return webClientBuilder.clientConnector(connector);
}
Also used : ReactorClientHttpConnector(org.springframework.http.client.reactive.ReactorClientHttpConnector) ClientHttpConnector(org.springframework.http.client.reactive.ClientHttpConnector) WriteTimeoutHandler(io.netty.handler.timeout.WriteTimeoutHandler) ReadTimeoutHandler(io.netty.handler.timeout.ReadTimeoutHandler) WebClient(org.springframework.web.reactive.function.client.WebClient) ReactorClientHttpConnector(org.springframework.http.client.reactive.ReactorClientHttpConnector) Bean(org.springframework.context.annotation.Bean)

Example 9 with ReactorClientHttpConnector

use of org.springframework.http.client.reactive.ReactorClientHttpConnector in project spring-boot-admin by codecentric.

the class QueryIndexEndpointStrategyTest method httpConnector.

private ReactorClientHttpConnector httpConnector() {
    SslContextBuilder sslCtx = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE);
    HttpClient client = HttpClient.create().secure((ssl) -> ssl.sslContext(sslCtx));
    return new ReactorClientHttpConnector(client);
}
Also used : SslContextBuilder(io.netty.handler.ssl.SslContextBuilder) HttpClient(reactor.netty.http.client.HttpClient) ReactorClientHttpConnector(org.springframework.http.client.reactive.ReactorClientHttpConnector)

Aggregations

ReactorClientHttpConnector (org.springframework.http.client.reactive.ReactorClientHttpConnector)9 WebClient (org.springframework.web.reactive.function.client.WebClient)5 Ssl (org.springframework.boot.web.server.Ssl)3 HttpClient (reactor.netty.http.client.HttpClient)3 Http11SslContextSpec (reactor.netty.http.Http11SslContextSpec)2 SslContextBuilder (io.netty.handler.ssl.SslContextBuilder)1 ReadTimeoutHandler (io.netty.handler.timeout.ReadTimeoutHandler)1 WriteTimeoutHandler (io.netty.handler.timeout.WriteTimeoutHandler)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 InetSocketAddress (java.net.InetSocketAddress)1 KeyStore (java.security.KeyStore)1 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)1 Test (org.junit.jupiter.api.Test)1 Bean (org.springframework.context.annotation.Bean)1 ClientHttpConnector (org.springframework.http.client.reactive.ClientHttpConnector)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1