@SuppressWarnings("deprecation") @Override protected AsyncClientHttpRequestFactory createRequestFactory() { return new Netty4ClientHttpRequestFactory(eventLoopGroup); }
private Bootstrap getBootstrap(URI uri) { boolean isSecure = (uri.getPort() == 443 || "https".equalsIgnoreCase(uri.getScheme())); if (isSecure) { return buildBootstrap(uri, true); } else { Bootstrap bootstrap = this.bootstrap; if (bootstrap == null) { bootstrap = buildBootstrap(uri, false); this.bootstrap = bootstrap; } return bootstrap; } }
@Override protected void initChannel(SocketChannel channel) throws Exception { configureChannel(channel.config()); ChannelPipeline pipeline = channel.pipeline(); if (isSecure) { Assert.notNull(sslContext, "sslContext should not be null"); pipeline.addLast(sslContext.newHandler(channel.alloc(), uri.getHost(), uri.getPort())); } pipeline.addLast(new HttpClientCodec()); pipeline.addLast(new HttpObjectAggregator(maxResponseSize)); if (readTimeout > 0) { pipeline.addLast(new ReadTimeoutHandler(readTimeout, TimeUnit.MILLISECONDS)); } } });
static ClientHttpRequestFactory usingNetty(ClientOptions options, SslConfiguration sslConfiguration) throws GeneralSecurityException, IOException { final Netty4ClientHttpRequestFactory requestFactory = new Netty4ClientHttpRequestFactory(); if (hasSslConfiguration(sslConfiguration)) { SslContextBuilder sslContextBuilder = SslContextBuilder // .forClient(); if (sslConfiguration.getTrustStoreConfiguration().isPresent()) { sslContextBuilder .trustManager(createTrustManagerFactory(sslConfiguration .getTrustStoreConfiguration())); } if (sslConfiguration.getKeyStoreConfiguration().isPresent()) { sslContextBuilder.keyManager(createKeyManagerFactory(sslConfiguration .getKeyStoreConfiguration())); } requestFactory.setSslContext(sslContextBuilder.sslProvider( SslProvider.JDK).build()); } requestFactory.setConnectTimeout(Math.toIntExact(options .getConnectionTimeout().toMillis())); requestFactory.setReadTimeout(Math.toIntExact(options.getReadTimeout() .toMillis())); return requestFactory; } }
@Override public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException { return createRequestInternal(uri, httpMethod); }
@Override public void afterPropertiesSet() { if (this.sslContext == null) { this.sslContext = getDefaultClientSslContext(); } }
private Netty4ClientHttpRequest createRequestInternal(URI uri, HttpMethod httpMethod) { return new Netty4ClientHttpRequest(getBootstrap(uri), uri, httpMethod); }
@Override public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException { return createRequestInternal(uri, httpMethod); }
@Override public void afterPropertiesSet() { if (this.sslContext == null) { this.sslContext = getDefaultClientSslContext(); } }
private Netty4ClientHttpRequest createRequestInternal(URI uri, HttpMethod httpMethod) { return new Netty4ClientHttpRequest(getBootstrap(uri), uri, httpMethod); }
@Override protected ClientHttpRequestFactory createRequestFactory() { return new Netty4ClientHttpRequestFactory(eventLoopGroup); }
@Override public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException { return createRequestInternal(uri, httpMethod); }
@Override public void afterPropertiesSet() { if (this.sslContext == null) { this.sslContext = getDefaultClientSslContext(); } }
private Bootstrap getBootstrap(URI uri) { boolean isSecure = (uri.getPort() == 443 || "https".equalsIgnoreCase(uri.getScheme())); if (isSecure) { return buildBootstrap(uri, true); } else { Bootstrap bootstrap = this.bootstrap; if (bootstrap == null) { bootstrap = buildBootstrap(uri, false); this.bootstrap = bootstrap; } return bootstrap; } }
private Netty4ClientHttpRequest createRequestInternal(URI uri, HttpMethod httpMethod) { return new Netty4ClientHttpRequest(getBootstrap(uri), uri, httpMethod); }
@Override protected void initChannel(SocketChannel channel) throws Exception { configureChannel(channel.config()); ChannelPipeline pipeline = channel.pipeline(); if (isSecure) { Assert.notNull(sslContext, "sslContext should not be null"); pipeline.addLast(sslContext.newHandler(channel.alloc(), uri.getHost(), uri.getPort())); } pipeline.addLast(new HttpClientCodec()); pipeline.addLast(new HttpObjectAggregator(maxResponseSize)); if (readTimeout > 0) { pipeline.addLast(new ReadTimeoutHandler(readTimeout, TimeUnit.MILLISECONDS)); } } });
@SuppressWarnings("deprecation") @org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean(ClientHttpRequestFactory.class) @org.springframework.context.annotation.Bean public ClientHttpRequestFactory defaultRequestFactory() { return new org.springframework.http.client.Netty4ClientHttpRequestFactory(); }
@Override public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException { return createRequestInternal(uri, httpMethod); }
@Override public void afterPropertiesSet() { if (this.sslContext == null) { this.sslContext = getDefaultClientSslContext(); } }
private Bootstrap getBootstrap(URI uri) { boolean isSecure = (uri.getPort() == 443 || "https".equalsIgnoreCase(uri.getScheme())); if (isSecure) { return buildBootstrap(uri, true); } else { Bootstrap bootstrap = this.bootstrap; if (bootstrap == null) { bootstrap = buildBootstrap(uri, false); this.bootstrap = bootstrap; } return bootstrap; } }