Skip to content Skip to sidebar Skip to footer

Okhttp Not Selecting Http2 On Android 7.0

I am trying to make an HTTP request to the following domain (http2 enabled) on a device running on Android 7.0. The code i use is as follows: Request request = new Request.Bu

Solution 1:

Android has enabled only HTTP/1.1 in its OkHttp.

/**
 * Creates an OkHttpClient suitable for creating HttpsURLConnection instances on
 * Android.
 */
public static OkUrlFactory createHttpsOkUrlFactory(Proxy proxy) {
  ...
  // Only enable HTTP/1.1 (implies HTTP/1.0). Disable SPDY / HTTP/2.0.
  okHttpClient.setProtocols(HTTP_1_1_ONLY);

https://android.googlesource.com/platform/external/okhttp/+/master/android/main/java/com/squareup/okhttp/HttpsHandler.java#75

Post a Comment for "Okhttp Not Selecting Http2 On Android 7.0"