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 import java.util.function.Function;
33
34 import org.apache.hc.client5.http.HttpRoute;
35 import org.apache.hc.client5.http.async.AsyncExecRuntime;
36 import org.apache.hc.client5.http.auth.AuthSchemeFactory;
37 import org.apache.hc.client5.http.auth.CredentialsProvider;
38 import org.apache.hc.client5.http.config.RequestConfig;
39 import org.apache.hc.client5.http.config.TlsConfig;
40 import org.apache.hc.client5.http.cookie.CookieSpecFactory;
41 import org.apache.hc.client5.http.cookie.CookieStore;
42 import org.apache.hc.client5.http.nio.AsyncClientConnectionManager;
43 import org.apache.hc.client5.http.protocol.HttpClientContext;
44 import org.apache.hc.client5.http.routing.HttpRoutePlanner;
45 import org.apache.hc.core5.annotation.Contract;
46 import org.apache.hc.core5.annotation.Internal;
47 import org.apache.hc.core5.annotation.ThreadingBehavior;
48 import org.apache.hc.core5.http.HttpException;
49 import org.apache.hc.core5.http.HttpHost;
50 import org.apache.hc.core5.http.HttpRequest;
51 import org.apache.hc.core5.http.config.Lookup;
52 import org.apache.hc.core5.http.nio.AsyncPushConsumer;
53 import org.apache.hc.core5.http.nio.HandlerFactory;
54 import org.apache.hc.core5.http.protocol.HttpContext;
55 import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
56 import org.slf4j.Logger;
57 import org.slf4j.LoggerFactory;
58
59
60
61
62
63
64
65
66
67
68
69
70 @Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
71 @Internal
72 public final class InternalHttpAsyncClient extends InternalAbstractHttpAsyncClient {
73
74 private static final Logger LOG = LoggerFactory.getLogger(InternalHttpAsyncClient.class);
75 private final AsyncClientConnectionManager manager;
76 private final HttpRoutePlanner routePlanner;
77 private final TlsConfig tlsConfig;
78
79 InternalHttpAsyncClient(
80 final DefaultConnectingIOReactor ioReactor,
81 final AsyncExecChainElement execChain,
82 final AsyncPushConsumerRegistry pushConsumerRegistry,
83 final ThreadFactory threadFactory,
84 final AsyncClientConnectionManager manager,
85 final HttpRoutePlanner routePlanner,
86 final TlsConfig tlsConfig,
87 final Lookup<CookieSpecFactory> cookieSpecRegistry,
88 final Lookup<AuthSchemeFactory> authSchemeRegistry,
89 final CookieStore cookieStore,
90 final CredentialsProvider credentialsProvider,
91 final Function<HttpContext, HttpClientContext> contextAdaptor,
92 final RequestConfig defaultConfig,
93 final List<Closeable> closeables) {
94 super(ioReactor, pushConsumerRegistry, threadFactory, execChain,
95 cookieSpecRegistry, authSchemeRegistry, cookieStore, credentialsProvider, contextAdaptor,
96 defaultConfig, closeables);
97 this.manager = manager;
98 this.routePlanner = routePlanner;
99 this.tlsConfig = tlsConfig;
100 }
101
102 @Override
103 AsyncExecRuntime createAsyncExecRuntime(final HandlerFactory<AsyncPushConsumer> pushHandlerFactory) {
104 return new InternalHttpAsyncExecRuntime(LOG, manager, getConnectionInitiator(), pushHandlerFactory, tlsConfig);
105 }
106
107 @Override
108 HttpRoute determineRoute(final HttpHost httpHost, final HttpRequest request, final HttpClientContext clientContext) throws HttpException {
109 return routePlanner.determineRoute(httpHost, request, clientContext);
110 }
111
112 }