1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.apache.hc.client5.http.impl.async;
28
29 import java.io.Closeable;
30 import java.util.List;
31 import java.util.concurrent.ThreadFactory;
32
33 import org.apache.hc.client5.http.HttpRoute;
34 import org.apache.hc.client5.http.async.AsyncExecRuntime;
35 import org.apache.hc.client5.http.auth.AuthSchemeFactory;
36 import org.apache.hc.client5.http.auth.CredentialsProvider;
37 import org.apache.hc.client5.http.config.RequestConfig;
38 import org.apache.hc.client5.http.config.TlsConfig;
39 import org.apache.hc.client5.http.cookie.CookieSpecFactory;
40 import org.apache.hc.client5.http.cookie.CookieStore;
41 import org.apache.hc.client5.http.nio.AsyncClientConnectionManager;
42 import org.apache.hc.client5.http.protocol.HttpClientContext;
43 import org.apache.hc.client5.http.routing.HttpRoutePlanner;
44 import org.apache.hc.core5.annotation.Contract;
45 import org.apache.hc.core5.annotation.Internal;
46 import org.apache.hc.core5.annotation.ThreadingBehavior;
47 import org.apache.hc.core5.http.HttpException;
48 import org.apache.hc.core5.http.HttpHost;
49 import org.apache.hc.core5.http.config.Lookup;
50 import org.apache.hc.core5.http.nio.AsyncPushConsumer;
51 import org.apache.hc.core5.http.nio.HandlerFactory;
52 import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
53 import org.slf4j.Logger;
54 import org.slf4j.LoggerFactory;
55
56
57
58
59
60
61
62
63
64
65
66
67 @Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
68 @Internal
69 public final class InternalHttpAsyncClient extends InternalAbstractHttpAsyncClient {
70
71 private static final Logger LOG = LoggerFactory.getLogger(InternalHttpAsyncClient.class);
72 private final AsyncClientConnectionManager manager;
73 private final HttpRoutePlanner routePlanner;
74 private final TlsConfig tlsConfig;
75
76 InternalHttpAsyncClient(
77 final DefaultConnectingIOReactor ioReactor,
78 final AsyncExecChainElement execChain,
79 final AsyncPushConsumerRegistry pushConsumerRegistry,
80 final ThreadFactory threadFactory,
81 final AsyncClientConnectionManager manager,
82 final HttpRoutePlanner routePlanner,
83 final TlsConfig tlsConfig,
84 final Lookup<CookieSpecFactory> cookieSpecRegistry,
85 final Lookup<AuthSchemeFactory> authSchemeRegistry,
86 final CookieStore cookieStore,
87 final CredentialsProvider credentialsProvider,
88 final RequestConfig defaultConfig,
89 final List<Closeable> closeables) {
90 super(ioReactor, pushConsumerRegistry, threadFactory, execChain,
91 cookieSpecRegistry, authSchemeRegistry, cookieStore, credentialsProvider, defaultConfig, closeables);
92 this.manager = manager;
93 this.routePlanner = routePlanner;
94 this.tlsConfig = tlsConfig;
95 }
96
97 @Override
98 AsyncExecRuntime createAsyncExecRuntime(final HandlerFactory<AsyncPushConsumer> pushHandlerFactory) {
99 return new InternalHttpAsyncExecRuntime(LOG, manager, getConnectionInitiator(), pushHandlerFactory, tlsConfig);
100 }
101
102 @Override
103 HttpRoute determineRoute(final HttpHost httpHost, final HttpClientContext clientContext) throws HttpException {
104 return routePlanner.determineRoute(httpHost, clientContext);
105 }
106
107 }