From 82960f417ea5deeceef496099e858e70a485cdf1 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Wed, 24 Mar 2021 12:34:10 +0100 Subject: [PATCH] clean up alpn protocol configuration Signed-off-by: Ludovic Orban --- .../jetty/http3/client/ClientQuicConnector.java | 8 ++------ .../http3/client/HttpClientTransportOverQuic.java | 12 ++++++++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/jetty-http3/http3-client/src/main/java/org/eclipse/jetty/http3/client/ClientQuicConnector.java b/jetty-http3/http3-client/src/main/java/org/eclipse/jetty/http3/client/ClientQuicConnector.java index 83331014be4..f72ed282d26 100644 --- a/jetty-http3/http3-client/src/main/java/org/eclipse/jetty/http3/client/ClientQuicConnector.java +++ b/jetty-http3/http3-client/src/main/java/org/eclipse/jetty/http3/client/ClientQuicConnector.java @@ -69,15 +69,11 @@ public class ClientQuicConnector extends ContainerLifeCycle implements IClientCo private SocketAddress bindAddress; private boolean reuseAddress = true; - public ClientQuicConnector(Origin.Protocol... protocols) + public ClientQuicConnector(Origin.Protocol protocol) { - String[] applicationProtos = Arrays.stream(protocols) - .flatMap(protocol -> protocol.getProtocols().stream()) - .toArray(String[]::new); - // TODO make the QuicheConfig configurable quicheConfig = new QuicheConfig(); - quicheConfig.setApplicationProtos(applicationProtos); + quicheConfig.setApplicationProtos(protocol.getProtocols().toArray(new String[0])); quicheConfig.setMaxIdleTimeout(5000L); quicheConfig.setInitialMaxData(10000000L); quicheConfig.setInitialMaxStreamDataBidiLocal(10000000L); diff --git a/jetty-http3/http3-client/src/main/java/org/eclipse/jetty/http3/client/HttpClientTransportOverQuic.java b/jetty-http3/http3-client/src/main/java/org/eclipse/jetty/http3/client/HttpClientTransportOverQuic.java index 16d27b9f7f3..ef25349279e 100644 --- a/jetty-http3/http3-client/src/main/java/org/eclipse/jetty/http3/client/HttpClientTransportOverQuic.java +++ b/jetty-http3/http3-client/src/main/java/org/eclipse/jetty/http3/client/HttpClientTransportOverQuic.java @@ -15,7 +15,10 @@ package org.eclipse.jetty.http3.client; import java.io.IOException; import java.net.InetSocketAddress; +import java.util.Arrays; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.eclipse.jetty.client.AbstractHttpClientTransport; import org.eclipse.jetty.client.HttpClient; @@ -41,8 +44,13 @@ public class HttpClientTransportOverQuic extends AbstractHttpClientTransport public HttpClientTransportOverQuic() { - //TODO the ClientConnectionFactory should be built according to the Protocol instance. See HttpClientTransportDynamic - protocol = new Origin.Protocol(HttpClientConnectionFactory.HTTP11.getProtocols(true), false); + this(HttpClientConnectionFactory.HTTP11); + } + + public HttpClientTransportOverQuic(ClientConnectionFactory.Info... factoryInfos) + { + List protocolNames = Arrays.stream(factoryInfos).flatMap(info -> info.getProtocols(true).stream()).collect(Collectors.toList()); + protocol = new Origin.Protocol(protocolNames, false); connector = new ClientQuicConnector(protocol); addBean(connector); setConnectionPoolFactory(destination ->