/** * Create a {@link ClientHttpConnector} for the given {@link ClientOptions} and * {@link SslConfiguration}. * * @param options must not be {@literal null} * @param sslConfiguration must not be {@literal null} * @return a new {@link ClientHttpConnector}. */ public static ClientHttpConnector create(ClientOptions options, SslConfiguration sslConfiguration) { return new ReactorClientHttpConnector(builder -> { if (hasSslConfiguration(sslConfiguration)) { builder.sslSupport(sslContextBuilder -> { configureSsl(sslConfiguration, sslContextBuilder); }).poolResources( PoolResources.elastic("vault-http-" + POOL_COUNTER.incrementAndGet())); } builder.sslHandshakeTimeout(options.getConnectionTimeout()); builder.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, Math.toIntExact(options.getConnectionTimeout().toMillis())); }); }
@Before public void setup(){ request = mock(ServerRequest.class); serviceLocator = mock(ReactiveBankServiceLocator.class); reactorLoanBrokerAgent = new ReactorLoanBrokerAgent(serviceLocator,WebClient.create(new ReactorClientHttpConnector())); loanBrokerHandler = new LoanBrokerHandler(reactorLoanBrokerAgent); }
private WebClient createSSLWebClient() throws IOException { /* Create a Reactor connector and tell it to trust our certificate */ final File pemFile = pemResource.getFile(); final ClientHttpConnector clientConnector = new ReactorClientHttpConnector( options -> options.sslSupport(builder -> builder.trustManager(pemFile))); /* Build a WebClient with the custom connector */ return WebClient.builder() .baseUrl(String.format("https://127.0.0.1:%d", port)) .clientConnector(clientConnector) .build(); }
@Override public RequestExecutor build(ExtendedClientCodecConfigurer codecConfigurer, ExchangeFilterFunction exchangeFilterFunction) { ExchangeStrategies exchangeStrategies = ExtendedExchangeStrategies.of(codecConfigurer); WebClient webClient = WebClient .builder() .filters(exchangeFilterFunctions -> { if (exchangeFilterFunction != null) { exchangeFilterFunctions.add(exchangeFilterFunction); } }) .exchangeFunction(ExchangeFunctions.create(new ReactorClientHttpConnector(), exchangeStrategies)) .build(); return new DefaultRequestExecutor(webClient); }
private static WebClient createDefaultWebClient(Duration connectTimeout, Duration readTimeout) { ReactorClientHttpConnector connector = new ReactorClientHttpConnector( options -> options.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, (int) connectTimeout.toMillis())// .compression(true)// .afterNettyContextInit(ctx -> { ctx.addHandlerLast( new ReadTimeoutHandler(readTimeout.toMillis(), TimeUnit.MILLISECONDS)); })); return WebClient.builder() .clientConnector(connector) .defaultHeader(HttpHeaders.ACCEPT, ActuatorMediaType.V2_JSON, ActuatorMediaType.V1_JSON, MediaType.APPLICATION_JSON_VALUE) .build(); }
public GitterClient(GitterProperties config) { this.webClient = WebClient.builder().clientConnector(new ReactorClientHttpConnector()).build() .filter(oAuthToken(config.getToken())); }
@Bean public WebClient webClient(){ return WebClient.create(new ReactorClientHttpConnector()); }
public static WebClient buildWebClient(String url) { ReactorClientHttpConnector connector = new ReactorClientHttpConnector( options -> options.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 3000)); return WebClient.builder().clientConnector(connector).baseUrl(url).build(); }
private WebClient buildWebClient(String url) { ReactorClientHttpConnector connector = new ReactorClientHttpConnector(options -> options.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 3000)); return WebClient.builder().clientConnector(connector).baseUrl(url).build(); }