Skip to content

Commit

Permalink
Disable HTTP/2 negotiation for trino-client/jdbc
Browse files Browse the repository at this point in the history
When Trino cluster is exposed through the proxy/LB that supports HTTP/2,
OkHttp client can negotiate and use HTTP/2. Since we don't have support for HTTP/2
in the Trino itself, this lacks testing and therefore should be unsupported.
  • Loading branch information
wendigo committed May 28, 2024
1 parent d8f7efa commit 0de7236
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.google.common.base.CharMatcher;
import com.google.common.base.StandardSystemProperty;
import com.google.common.collect.ImmutableList;
import com.google.common.net.HostAndPort;
import io.trino.client.auth.kerberos.DelegatedConstrainedContextProvider;
import io.trino.client.auth.kerberos.DelegatedUnconstrainedContextProvider;
Expand All @@ -25,6 +26,7 @@
import okhttp3.Interceptor;
import okhttp3.JavaNetCookieJar;
import okhttp3.OkHttpClient;
import okhttp3.Protocol;
import okhttp3.internal.tls.LegacyHostnameVerifier;
import org.ietf.jgss.GSSCredential;

Expand Down Expand Up @@ -111,6 +113,12 @@ public static void setupCookieJar(OkHttpClient.Builder clientBuilder)
clientBuilder.cookieJar(new JavaNetCookieJar(new CookieManager()));
}

public static void disableHttp2(OkHttpClient.Builder clientBuilder)
{
// Disable HTTP/2 as it's not tested nor supported
clientBuilder.protocols(ImmutableList.of(Protocol.HTTP_1_1, Protocol.HTTP_1_1));
}

public static void setupSocksProxy(OkHttpClient.Builder clientBuilder, Optional<HostAndPort> socksProxy)
{
setupProxy(clientBuilder, socksProxy, SOCKS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static io.trino.client.KerberosUtil.defaultCredentialCachePath;
import static io.trino.client.OkHttpUtil.basicAuth;
import static io.trino.client.OkHttpUtil.disableHttp2;
import static io.trino.client.OkHttpUtil.setupAlternateHostnameVerification;
import static io.trino.client.OkHttpUtil.setupCookieJar;
import static io.trino.client.OkHttpUtil.setupHttpProxy;
Expand Down Expand Up @@ -603,6 +604,7 @@ public void setupClient(OkHttpClient.Builder builder)
throws SQLException
{
try {
disableHttp2(builder);
setupCookieJar(builder);
setupSocksProxy(builder, socksProxy);
setupHttpProxy(builder, httpProxy);
Expand Down

0 comments on commit 0de7236

Please sign in to comment.