this.defaultCharset = configuration.getDefaultCharset(); this.contextPath = contextPath; this.bootstrap = new Bootstrap(); .option(ChannelOption.SO_KEEPALIVE, true); HttpClientConfiguration.ConnectionPoolConfiguration connectionPoolConfiguration = configuration.getConnectionPoolConfiguration(); if (connectionPoolConfiguration.isEnabled()) { int maxConnections = connectionPoolConfiguration.getMaxConnections(); Optional<Duration> connectTimeout = configuration.getConnectTimeout(); connectTimeout.ifPresent(duration -> this.bootstrap.option( ChannelOption.CONNECT_TIMEOUT_MILLIS, )); for (Map.Entry<ChannelOption, Object> entry : configuration.getChannelOptions().entrySet()) { Object v = entry.getValue(); if (v != null) { this.filters = filters; this.annotationMetadataResolver = annotationMetadataResolver != null ? annotationMetadataResolver : AnnotationMetadataResolver.DEFAULT; this.log = configuration.getLoggerName() .map(LoggerFactory::getLogger).orElse(LOG);
Optional<SocketAddress> proxy = configuration.getProxyAddress(); if (proxy.isPresent()) { Type proxyType = configuration.getProxyType(); SocketAddress proxyAddress = proxy.get(); configureProxy(p, proxyType, proxyAddress); Optional<Duration> readTimeout = configuration.getReadTimeout(); readTimeout.ifPresent(duration -> { if (!duration.isNegative()) { Optional<Duration> readIdleTime = configuration.getReadIdleTimeout(); if (readIdleTime.isPresent()) { Duration duration = readIdleTime.get(); int maxContentLength = configuration.getMaxContentLength(); configuration.getMaxContentLength(), true, true
/** * Creates the {@link NioEventLoopGroup} for this client. * * @param configuration The configuration * @param threadFactory The thread factory * @return The group */ protected NioEventLoopGroup createEventLoopGroup(HttpClientConfiguration configuration, ThreadFactory threadFactory) { OptionalInt numOfThreads = configuration.getNumOfThreads(); Optional<Class<? extends ThreadFactory>> threadFactoryType = configuration.getThreadFactory(); boolean hasThreads = numOfThreads.isPresent(); boolean hasFactory = threadFactoryType.isPresent(); NioEventLoopGroup group; if (hasThreads && hasFactory) { group = new NioEventLoopGroup(numOfThreads.getAsInt(), InstantiationUtils.instantiate(threadFactoryType.get())); } else if (hasThreads) { if (threadFactory != null) { group = new NioEventLoopGroup(numOfThreads.getAsInt(), threadFactory); } else { group = new NioEventLoopGroup(numOfThreads.getAsInt()); } } else { if (threadFactory != null) { group = new NioEventLoopGroup(NettyThreadFactory.DEFAULT_EVENT_LOOP_THREADS, threadFactory); } else { group = new NioEventLoopGroup(); } } return group; }
String username = configuration.getProxyUsername().orElse(null); String password = configuration.getProxyPassword().orElse(null);
String username = configuration.getProxyUsername().orElse(null); String password = configuration.getProxyPassword().orElse(null);
this.defaultCharset = configuration.getDefaultCharset(); this.contextPath = contextPath; this.bootstrap = new Bootstrap(); .option(ChannelOption.SO_KEEPALIVE, true); HttpClientConfiguration.ConnectionPoolConfiguration connectionPoolConfiguration = configuration.getConnectionPoolConfiguration(); if (connectionPoolConfiguration.isEnabled()) { int maxConnections = connectionPoolConfiguration.getMaxConnections(); Optional<Duration> connectTimeout = configuration.getConnectTimeout(); connectTimeout.ifPresent(duration -> this.bootstrap.option( ChannelOption.CONNECT_TIMEOUT_MILLIS, )); for (Map.Entry<ChannelOption, Object> entry : configuration.getChannelOptions().entrySet()) { Object v = entry.getValue(); if (v != null) { this.filters = filters; this.annotationMetadataResolver = annotationMetadataResolver != null ? annotationMetadataResolver : AnnotationMetadataResolver.DEFAULT; this.log = configuration.getLoggerName() .map(LoggerFactory::getLogger).orElse(LOG);
Optional<SocketAddress> proxy = configuration.getProxyAddress(); if (proxy.isPresent()) { Type proxyType = configuration.getProxyType(); SocketAddress proxyAddress = proxy.get(); configureProxy(p, proxyType, proxyAddress); Optional<Duration> readTimeout = configuration.getReadTimeout(); readTimeout.ifPresent(duration -> { if (!duration.isNegative()) { Optional<Duration> readIdleTime = configuration.getReadIdleTimeout(); if (readIdleTime.isPresent()) { Duration duration = readIdleTime.get(); int maxContentLength = configuration.getMaxContentLength(); configuration.getMaxContentLength(), true, true
String username = configuration.getProxyUsername().orElse(null); String password = configuration.getProxyPassword().orElse(null);
/** * Creates the {@link NioEventLoopGroup} for this client. * * @param configuration The configuration * @param threadFactory The thread factory * @return The group */ protected NioEventLoopGroup createEventLoopGroup(HttpClientConfiguration configuration, ThreadFactory threadFactory) { OptionalInt numOfThreads = configuration.getNumOfThreads(); Optional<Class<? extends ThreadFactory>> threadFactoryType = configuration.getThreadFactory(); boolean hasThreads = numOfThreads.isPresent(); boolean hasFactory = threadFactoryType.isPresent(); NioEventLoopGroup group; if (hasThreads && hasFactory) { group = new NioEventLoopGroup(numOfThreads.getAsInt(), InstantiationUtils.instantiate(threadFactoryType.get())); } else if (hasThreads) { if (threadFactory != null) { group = new NioEventLoopGroup(numOfThreads.getAsInt(), threadFactory); } else { group = new NioEventLoopGroup(numOfThreads.getAsInt()); } } else { if (threadFactory != null) { group = new NioEventLoopGroup(NettyThreadFactory.DEFAULT_EVENT_LOOP_THREADS, threadFactory); } else { group = new NioEventLoopGroup(); } } return group; }
this.defaultCharset = configuration.getDefaultCharset(); this.contextPath = contextPath; this.bootstrap = new Bootstrap(); .option(ChannelOption.SO_KEEPALIVE, true); HttpClientConfiguration.ConnectionPoolConfiguration connectionPoolConfiguration = configuration.getConnectionPoolConfiguration(); if (connectionPoolConfiguration.isEnabled()) { int maxConnections = connectionPoolConfiguration.getMaxConnections(); Optional<Duration> connectTimeout = configuration.getConnectTimeout(); connectTimeout.ifPresent(duration -> this.bootstrap.option( ChannelOption.CONNECT_TIMEOUT_MILLIS, )); for (Map.Entry<ChannelOption, Object> entry : configuration.getChannelOptions().entrySet()) { Object v = entry.getValue(); if (v != null) { this.filters = filters; this.annotationMetadataResolver = annotationMetadataResolver != null ? annotationMetadataResolver : AnnotationMetadataResolver.DEFAULT; this.log = configuration.getLoggerName() .map(LoggerFactory::getLogger).orElse(LOG);
Optional<SocketAddress> proxy = configuration.getProxyAddress(); if (proxy.isPresent()) { Type proxyType = configuration.getProxyType(); SocketAddress proxyAddress = proxy.get(); configureProxy(p, proxyType, proxyAddress); Optional<Duration> readTimeout = configuration.getReadTimeout(); readTimeout.ifPresent(duration -> { if (!duration.isNegative()) { Optional<Duration> readIdleTime = configuration.getReadIdleTimeout(); if (readIdleTime.isPresent()) { Duration duration = readIdleTime.get(); int maxContentLength = configuration.getMaxContentLength(); configuration.getMaxContentLength(), true, true
/** * Creates the {@link NioEventLoopGroup} for this client. * * @param configuration The configuration * @param threadFactory The thread factory * @return The group */ protected NioEventLoopGroup createEventLoopGroup(HttpClientConfiguration configuration, ThreadFactory threadFactory) { OptionalInt numOfThreads = configuration.getNumOfThreads(); Optional<Class<? extends ThreadFactory>> threadFactoryType = configuration.getThreadFactory(); boolean hasThreads = numOfThreads.isPresent(); boolean hasFactory = threadFactoryType.isPresent(); NioEventLoopGroup group; if (hasThreads && hasFactory) { group = new NioEventLoopGroup(numOfThreads.getAsInt(), InstantiationUtils.instantiate(threadFactoryType.get())); } else if (hasThreads) { if (threadFactory != null) { group = new NioEventLoopGroup(numOfThreads.getAsInt(), threadFactory); } else { group = new NioEventLoopGroup(numOfThreads.getAsInt()); } } else { if (threadFactory != null) { group = new NioEventLoopGroup(NettyThreadFactory.DEFAULT_EVENT_LOOP_THREADS, threadFactory); } else { group = new NioEventLoopGroup(); } } return group; }