mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-21 02:26:18 +08:00
Upgrade to OkHttp3
Summary: Update to [OkHttp](https://github.com/square/okhttp) to [OkHttp3](https://publicobject.com/2015/12/12/com-squareup-okhttp3/) We must also update: - Fresco to 0.10.0 - okio to 1.8.0 **Motivation** Reasons for upgrading: * Issue #4021 * "We discovered that RN Android sometimes fails to connect to the latest stable version of NGINX when HTTP/2 is enabled. We aren't seeing errors with other HTTP clients so we think it's specific to RN and OkHttp. Square has fixed several HTTP/2 bugs over the past eight months." - ide * OkHttp3 will be maintained & improved, but OkHttp2 will only receive [security fixes](https://publicobject.com/2016/02/11/okhttp-certificate-pinning-vulnerability/) * Cleaner APIs - "Get and Set prefixes are avoided" * Deprecated/Removed - HttpURLConnection & Apache HTTP * React Native apps are currently being forced to bundle two versions of OkHttp (v2 & v3), if another library uses v3 * Improved WebSocket performance - [CHANGELOG.md](https://github.com/square/okhttp/blob/master Closes https://github.com/facebook/react-native/pull/6113 Reviewed By: andreicoman11, lexs Differential Revision: D3292375 Pulled By: bestander fbshipit-source-id: 7c7043eaa2ea63f95854108b401c4066098d67f7
This commit is contained in:
committed by
Facebook Github Bot 1
parent
5047f6f54c
commit
6bbaff2944
@@ -4,21 +4,21 @@ android_library(
|
||||
name = 'fresco',
|
||||
srcs = glob(['**/*.java']),
|
||||
deps = [
|
||||
react_native_target('java/com/facebook/react/bridge:bridge'),
|
||||
react_native_target('java/com/facebook/react/modules/common:common'),
|
||||
react_native_target('java/com/facebook/react/modules/network:network'),
|
||||
react_native_dep('java/com/facebook/systrace:systrace'),
|
||||
react_native_dep('libraries/fresco/fresco-react-native:fbcore'),
|
||||
react_native_dep('libraries/fresco/fresco-react-native:fresco-drawee'),
|
||||
react_native_dep('libraries/fresco/fresco-react-native:fresco-react-native'),
|
||||
react_native_dep('libraries/fresco/fresco-react-native:imagepipeline'),
|
||||
react_native_dep('libraries/fresco/fresco-react-native:imagepipeline-okhttp'),
|
||||
react_native_dep('libraries/fresco/fresco-react-native:imagepipeline-okhttp3'),
|
||||
react_native_dep('libraries/soloader/java/com/facebook/soloader:soloader'),
|
||||
react_native_dep('third-party/android/support-annotations:android-support-annotations'),
|
||||
react_native_dep('third-party/android/support/v4:lib-support-v4'),
|
||||
react_native_dep('third-party/java/jsr-305:jsr-305'),
|
||||
react_native_dep('third-party/java/okhttp:okhttp'),
|
||||
react_native_dep('libraries/fresco/fresco-react-native:fbcore'),
|
||||
react_native_dep('libraries/fresco/fresco-react-native:fresco-drawee'),
|
||||
],
|
||||
react_native_dep('third-party/java/okhttp:okhttp3'),
|
||||
react_native_target('java/com/facebook/react/bridge:bridge'),
|
||||
react_native_target('java/com/facebook/react/modules/common:common'),
|
||||
react_native_target('java/com/facebook/react/modules/network:network'),
|
||||
],
|
||||
visibility = [
|
||||
'PUBLIC',
|
||||
],
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.facebook.cache.disk.DiskCacheConfig;
|
||||
import com.facebook.common.internal.AndroidPredicates;
|
||||
import com.facebook.common.soloader.SoLoaderShim;
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.imagepipeline.backends.okhttp.OkHttpImagePipelineConfigFactory;
|
||||
import com.facebook.imagepipeline.backends.okhttp3.OkHttpImagePipelineConfigFactory;
|
||||
import com.facebook.imagepipeline.core.ImagePipelineConfig;
|
||||
import com.facebook.imagepipeline.core.ImagePipelineFactory;
|
||||
import com.facebook.imagepipeline.listener.RequestListener;
|
||||
@@ -29,7 +29,7 @@ import com.facebook.react.modules.common.ModuleDataCleaner;
|
||||
import com.facebook.react.modules.network.OkHttpClientProvider;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
import com.squareup.okhttp.OkHttpClient;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
/**
|
||||
* Module to initialize the Fresco library.
|
||||
@@ -84,8 +84,8 @@ public class FrescoModule extends ReactContextBaseJavaModule implements
|
||||
ImagePipelineFactory imagePipelineFactory = Fresco.getImagePipelineFactory();
|
||||
imagePipelineFactory.getBitmapMemoryCache().removeAll(AndroidPredicates.<CacheKey>True());
|
||||
imagePipelineFactory.getEncodedMemoryCache().removeAll(AndroidPredicates.<CacheKey>True());
|
||||
imagePipelineFactory.getMainDiskStorageCache().clearAll();
|
||||
imagePipelineFactory.getSmallImageDiskStorageCache().clearAll();
|
||||
imagePipelineFactory.getMainFileCache().clearAll();
|
||||
imagePipelineFactory.getSmallImageFileCache().clearAll();
|
||||
}
|
||||
|
||||
private static ImagePipelineConfig getDefaultConfig(
|
||||
|
||||
Reference in New Issue
Block a user