diff options
author | Antonio Zugaldia <antonio@mapbox.com> | 2017-10-24 13:51:18 -0400 |
---|---|---|
committer | Antonio Zugaldia <antonio@mapbox.com> | 2017-10-24 13:51:18 -0400 |
commit | 6c4321dca81919ce3f4f9cff560cff22ea7a98b8 (patch) | |
tree | 22c75f4d662b5187d2f277b28027182da509a9e4 | |
parent | af904467582e79d8dbf2a405776a81131ff1fa11 (diff) | |
download | qtlocation-mapboxgl-upstream/az-dispatcher-limit.tar.gz |
[android] set a larger limit for the http dispatcherupstream/az-dispatcher-limit
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java | 11 |
1 files changed, 10 insertions, 1 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 e2626a026b..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, |