Skip to content

Commit

Permalink
enable http2 in okhttp
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hrj committed Aug 4, 2015
1 parent e775c87 commit fe8fcec
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Platform_Core/org/lobobrowser/main/PlatformInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<Protocol> 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);
Expand Down

0 comments on commit fe8fcec

Please sign in to comment.