99import io .vertx .core .internal .CloseFuture ;
1010import io .vertx .core .internal .ContextInternal ;
1111import io .vertx .core .internal .VertxInternal ;
12+ import io .vertx .core .internal .http .HttpClientTransport ;
1213import io .vertx .core .internal .http .HttpClientInternal ;
1314import io .vertx .core .internal .net .NetClientInternal ;
1415import io .vertx .core .net .ProxyOptions ;
@@ -116,11 +117,12 @@ private EndpointResolver endpointResolver(HttpClientConfig co) {
116117 return null ;
117118 }
118119
119- private HttpClientImpl createHttpClientImpl (HttpClientMetrics <?, ?, ?> metrics ,
120+ private HttpClientImpl createHttpClientImpl (HttpClientConfig clientConfig ,
121+ HttpClientMetrics <?, ?, ?> metrics ,
120122 EndpointResolver resolver ,
121123 Function <HttpClientResponse , Future <RequestOptions >> redirectHandler ,
122- HttpClientImpl . Transport config ,
123- HttpClientImpl . Transport quicTransport ) {
124+ HttpClientTransport tcpTransport ,
125+ HttpClientTransport quicTransport ) {
124126 boolean followAlternativeServices ;
125127 ProxyOptions proxyOptions ;
126128 List <String > nonProxyHosts ;
@@ -136,8 +138,28 @@ private HttpClientImpl createHttpClientImpl(HttpClientMetrics<?, ?, ?> metrics,
136138 PoolOptions po ;
137139 po = poolOptions != null ? poolOptions : new PoolOptions ();
138140 HttpClientOptions options = HttpClientBuilderInternal .this .clientOptions ;
139- return new HttpClientImpl (vertx , resolver , redirectHandler , metrics , po ,
140- proxyOptions , nonProxyHosts , loadBalancer , followAlternativeServices , resolverKeepAlive , config , quicTransport ) {
141+ Handler <HttpConnection > connectHandler = connectionHandler (clientConfig );
142+ return new HttpClientImpl (
143+ vertx ,
144+ resolver ,
145+ redirectHandler ,
146+ metrics ,
147+ po ,
148+ proxyOptions ,
149+ nonProxyHosts ,
150+ loadBalancer ,
151+ followAlternativeServices ,
152+ resolverKeepAlive ,
153+ clientConfig .isVerifyHost (),
154+ clientConfig .isSsl (),
155+ clientConfig .getDefaultHost (),
156+ clientConfig .getDefaultPort (),
157+ clientConfig .getMaxRedirects (),
158+ clientConfig .getDefaultProtocolVersion (),
159+ clientConfig .getSslOptions (),
160+ connectHandler ,
161+ tcpTransport ,
162+ quicTransport ) {
141163 @ Override
142164 public HttpClientOptions options () {
143165 return options == null ? new HttpClientOptions () : new HttpClientOptions (options );
@@ -175,7 +197,9 @@ private Handler<HttpConnection> connectionHandler(HttpClientConfig options) {
175197 Handler <HttpConnection > handler = connectHandler ;
176198 if (windowSize > 0 ) {
177199 return connection -> {
178- connection .setWindowSize (windowSize );
200+ if (connection .protocolVersion () == HttpVersion .HTTP_2 ) {
201+ connection .setWindowSize (windowSize );
202+ }
179203 if (handler != null ) {
180204 handler .handle (connection );
181205 }
@@ -193,31 +217,17 @@ public HttpClientAgent build() {
193217 co = new HttpClientConfig (new HttpClientOptions ());
194218 }
195219
196- // Copy options here ????
197- HttpClientImpl .Transport quicTransport ;
220+ HttpClientTransport quicTransport ;
198221 HttpClientMetrics <?, ?, ?> metrics ;
199222 if (co .getHttp3Config () != null ) {
200223 metrics = vertx .metrics () != null ? vertx .metrics ().createHttpClientMetrics (new HttpClientOptions ()) : null ;
201- quicTransport = new HttpClientImpl .Transport (
202- connectHandler ,
203- new Http3ChannelConnector (vertx , metrics , co ),
204- co .isVerifyHost (),
205- true ,
206- co .getDefaultHost (),
207- co .getDefaultPort (),
208- co .getMaxRedirects (),
209- HttpVersion .HTTP_3 ,
210- co .getSslOptions ()
211- );
224+ quicTransport = new Http3ClientTransport (vertx , metrics , co );
212225 } else {
213226 quicTransport = null ;
214227 metrics = null ;
215- if (co == null ) {
216- co = new HttpClientConfig ();
217- }
218228 }
219229
220- HttpClientImpl . Transport transport ;
230+ HttpClientTransport transport ;
221231 String shared ;
222232 EndpointResolver resolver ;
223233 if (co .getHttp1Config () != null && co .getHttp2Config () != null ) {
@@ -229,40 +239,30 @@ public HttpClientAgent build() {
229239 }
230240 NetClientConfig netClientConfig = netClientConfig (co );
231241 NetClientInternal tcpClient = new NetClientBuilder (vertx , netClientConfig .setProxyOptions (null )).metrics (metrics ).build ();
232- Handler <HttpConnection > connectHandler = connectionHandler (co );
233- transport = new HttpClientImpl .Transport (
234- connectHandler ,
235- Http1xOrH2ChannelConnector .create (tcpClient , co , metrics ),
236- co .isVerifyHost (),
237- co .isSsl (),
238- co .getDefaultHost (),
239- co .getDefaultPort (),
240- co .getMaxRedirects (),
241- co .getDefaultProtocolVersion (),
242- co .getSslOptions ()
243- );
242+ transport = Http1xOrH2ClientTransport .create (tcpClient , co , metrics );
244243 } else {
245244 resolver = null ;
246245 transport = null ;
247246 shared = null ;
248247 }
249248
250249
250+ HttpClientConfig co2 = co ;
251251 CloseFuture cf = resolveCloseFuture ();
252252 HttpClientAgent client ;
253253 Closeable closeable ;
254254 if (shared != null ) {
255255 CloseFuture closeFuture = new CloseFuture ();
256256 HttpClientMetrics <?, ?, ?> m = metrics ;
257257 client = vertx .createSharedResource ("__vertx.shared.httpClients" , co .getName (), closeFuture , cf_ -> {
258- HttpClientImpl impl = createHttpClientImpl (m , resolver , redirectHandler , transport , quicTransport );
258+ HttpClientImpl impl = createHttpClientImpl (co2 , m , resolver , redirectHandler , transport , quicTransport );
259259 cf_ .add (completion -> impl .close ().onComplete (completion ));
260260 return impl ;
261261 });
262262 client = new CleanableHttpClient ((HttpClientInternal ) client , vertx .cleaner (), (timeout , timeunit ) -> closeFuture .close ());
263263 closeable = closeFuture ;
264264 } else {
265- HttpClientImpl impl = createHttpClientImpl (metrics , resolver , redirectHandler , transport , quicTransport );
265+ HttpClientImpl impl = createHttpClientImpl (co2 , metrics , resolver , redirectHandler , transport , quicTransport );
266266 closeable = impl ;
267267 client = new CleanableHttpClient (impl , vertx .cleaner (), impl ::shutdown );
268268 }
0 commit comments