diff options
author | Antonio Zugaldia <antonio@mapbox.com> | 2017-11-27 10:33:14 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-27 10:33:14 -0500 |
commit | 85bc035be333b166ace6c3029dcbf89bb1e831e9 (patch) | |
tree | 3b90abe11570ccb9d66bcfd959aa2326488955ba | |
parent | 7c8fbc82323f6a7cb8462c6843cf6d43b0eaf46a (diff) | |
download | qtlocation-mapboxgl-85bc035be333b166ace6c3029dcbf89bb1e831e9.tar.gz |
[android] Set a larger limit for the HTTP dispatcher (#10567)
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java index f25ecd4d4d..9c7fe4ee63 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java @@ -22,6 +22,7 @@ import javax.net.ssl.SSLException; import okhttp3.Call; import okhttp3.Callback; +import okhttp3.Dispatcher; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -31,7 +32,7 @@ import timber.log.Timber; class HTTPRequest implements Callback { - private static OkHttpClient mClient = new OkHttpClient(); + private static OkHttpClient mClient = new OkHttpClient.Builder().dispatcher(getDispatcher()).build(); private String USER_AGENT_STRING = null; private static final int CONNECTION_ERROR = 0; @@ -47,6 +48,14 @@ class HTTPRequest implements Callback { private Call mCall; private Request mRequest; + private static Dispatcher getDispatcher() { + Dispatcher dispatcher = new Dispatcher(); + // Matches core limit set on + // https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/src/http_file_source.cpp#L192 + dispatcher.setMaxRequestsPerHost(20); + return dispatcher; + } + private native void nativeOnFailure(int type, String message); private native void nativeOnResponse(int code, String etag, String modified, String cacheControl, String expires, @@ -55,7 +64,6 @@ class HTTPRequest implements Callback { private HTTPRequest(long nativePtr, String resourceUrl, String etag, String modified) { mNativePtr = nativePtr; - Timber.e("requesting: %s",resourceUrl); try { HttpUrl httpUrl = HttpUrl.parse(resourceUrl); final String host = httpUrl.host().toLowerCase(MapboxConstants.MAPBOX_LOCALE); |