From fe8fcec503797b4b0f0d98098751e88ed6fa80f6 Mon Sep 17 00:00:00 2001 From: hrj Date: Wed, 5 Aug 2015 01:09:07 +0530 Subject: [PATCH] enable http2 in okhttp It doesn't actually work yet because of limitations of current JRE See gh-115 Enabling it anyway, in case it starts working when the JRE is updated. --- src/Platform_Core/org/lobobrowser/main/PlatformInit.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Platform_Core/org/lobobrowser/main/PlatformInit.java b/src/Platform_Core/org/lobobrowser/main/PlatformInit.java index 3c46fa71..ad315950 100644 --- a/src/Platform_Core/org/lobobrowser/main/PlatformInit.java +++ b/src/Platform_Core/org/lobobrowser/main/PlatformInit.java @@ -37,6 +37,7 @@ import java.security.PrivilegedAction; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.EventObject; import java.util.Locale; @@ -66,6 +67,7 @@ import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.OkUrlFactory; +import com.squareup.okhttp.Protocol; /** * A singleton class that is used to initialize a browser session in the current @@ -114,6 +116,12 @@ public void initProtocols(final SSLSocketFactory sslSocketFactory) { final PlatformStreamHandlerFactory factory = PlatformStreamHandlerFactory.getInstance(); URL.setURLStreamHandlerFactory(factory); final OkHttpClient okHttpClient = new OkHttpClient(); + + final ArrayList protocolList = new ArrayList<>(2); + protocolList.add(Protocol.HTTP_1_1); + protocolList.add(Protocol.HTTP_2); + okHttpClient.setProtocols(protocolList); + // HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory); okHttpClient.setSslSocketFactory(sslSocketFactory); okHttpClient.setFollowRedirects(false);